Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Crontab is used in Linux distributions to schedule jobs.  It can be scheduled for specific minute(s), hour(s), day(s), and so forth.  More information can be seen here. The Wikipedia article explains it fairly well also. For more information on the SSDT Supplied Scripts, see this page.

Crontab Basics

Look at existing crontab

...

These daily updates can be logged.  The > syntax overwrites any exiting logfile with the same fully qualified name, and >> appends to any existing logfile with the same fully qualified name (and it will create one if none exists).

A date can be added to the log file name.  Note when adding a date, use ` (it is generally on the ~ key) and not '. 

In the following example, jobs are scheduled on a daily basis (as the root user)  to update the ssdt utilities at 1:00 a.m., updated images are pulled at 1:10 a.m., updates to the /data/pilot directory tree are applied at 1:30 a.m. Also, the results of each job is written to a logfile as specified.

Code Block
##to overwrite exiting logfiles, entries should be:
0 1 * * *   /ssdt/update.sh 2>&1 > /data/pilot/update-utilities.log
10 1 * * *   /ssdt/scripts/updates-pull.sh 2>&1 > /data/pilot/updates-pull.log
30 1 * * *  /ssdt/scripts/updates-apply.sh /data/pilot 2>&1 > /data/pilot/updates-apply.log

##to append to exiting logfiles (and create a new one if none exists), entries should be:
0 1 * * *   /ssdt/update.sh 2>&1 >> /data/pilot/update-utilities.log
10 1 * * *   /ssdt/scripts/updates-pull.sh 2>&1 >> /data/pilot/updates-pull.log
30 1 * * *  /ssdt/scripts/updates-apply.sh /data/pilot 2>&1 >> /data/pilot/updates-apply.log

##Example creating logfiles with specific dates
##update utilities at 1:00 a.m. and write to /data/pilot/update-utilities-year-month-day-hour:minute.log (adds a date to the logfile name)
##example logfile name with this command:  update-utilities-2017-09-27-01:00.log
0 1 * * *   /ssdt/update.sh 2>&1 > /data/pilot/update-utilities-`date +\%Y-\%m-\%d-\%H:\%M`.log

If desired, a job could be added to cleanup any unused ssdt images by adding the following line (in this example, unused images are cleaned up at 2:00 every Saturday).  The log is overwritten.  You could add a date to the logfile name as in the above examples.

Code Block
0 2 * * 6   /ssdt/scripts/updates-cleanup.sh 2>&1 > /data/pilot/updates-cleanup.log

...

USXS backup basics are described hereThese can be automated.  Note this is a work in progress and details need to be placed here.In order to automate these backups, the exec-all-projects.sh script must be used along with the backup-usxs.sh script.

Code Block
## backup usps databases for running containers in the /data/pilot directory tree at 1:40 and append to the log file
## backup usas databases for running containers in the /data/pilot directory tree at 1:45 and append to the log file
40 1 * * *  /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/scripts/backup-usps.sh 2>&1 >> /data/pilot/backup-usps.log
45 1 * * *  /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/scripts/backup-usas.sh 2>&1 >> /data/pilot/backup-usas.log

Example of a full cron job

In this job, utilities updates are pulled daily at 1:00 a.m. Available release updates are pulled at 1:10 a.m. and applied at 1:30 a.m.  At 1:40 a.m., all usas databases for instances running in /data/pilot directory tree are backed up, and the usps ones are backed up at 1:45 a.m.  Image cleanup is performed every Saturday at 2:00 a.m.  With the exception of the cleanup log, dates are placed in the name of the logs.

Code Block
0 1 * * *   /ssdt/update.sh  2>&1 >> /data/pilot/update-utilities-`date +\%Y-\%m-\%d-\%H:\%M`.log
10 1 * * *   /ssdt/scripts/updates-pull.sh 2>&1 >> /data/pilot/updates-pull-`date +\%Y-\%m-\%d-\%H:\%M`.log
30 1 * * *  /ssdt/scripts/updates-apply.sh /data/pilot 2>&1 >> /data/pilot/updates-apply-`date +\%Y-\%m-\%d-\%H:\%M`.log
40 1 * * *  /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/scripts/backup-usps.sh 2>&1 >> /data/pilot/backup-usps-`date +\%Y-\%m-\%d-\%H:\%M`.log
45 1 * * *  /ssdt/scripts/exec-all-projects.sh /data/pilot /ssdt/scripts/backup-usas.sh 2>&1 >> /data/pilot/backup-usas-`date +\%Y-\%m-\%d-\%H:\%M`.log
0 2 * * 6   /ssdt/scripts/updates-cleanup.sh 2>&1 > /data/pilot/updates-cleanup.log