// Using Cron on Discover

Cron is available via the alias "discover-cron". Rather than enabling cron on every login node, discover-cron is a single login class node that handles all of the cron work on Discover. It has access to all of the same GPFS filesystems as the other Discover nodes as well as the same NFS filesystems as the other login nodes. The crontab files for all users are backed up daily.

Important: Make sure you have set up your ssh keys so that you can traverse between Discover login nodes.

To get to discover-cron, once logged into the Discover cluster, run: $ ssh discover-cron

To access and edit the crontab, run: $ crontab -e

Cron is run using a bash environment only, it will not use your default shell environment. Users are recommended to refer to the man pages for more information on crontab and writing/running bash scripts. To access these man pages, run: $ man bash
$ man cron
$ man crontab

Crontab Structure and Examples

  -------------- minute (0 - 59)
 |  .----------- hour (0 - 23)
 |  | .--------- day of month (1 - 31)
 |  | | .------- month (1 - 12) or jan,feb,mar...
 |  | | | .----- day of week (0 - 6) (Sunday=0)
 |  | | | |
 *  * * * * <command>
The [*] means every possible unit (i.e. every minute of every hour throughout the year, unless otherwise specified).

15 * * * * ( ssh discover-cas <command> <command_args> ) At 15 minutes after the hour, every hour, this will ssh to discover-cas and run <command>.

21 13 * * * mycron.csh 1> FULLPATH/test.out 2>/dev/null
52  * * * * showquota 1>> FULLPATH/test.out 2>&1
21 13 * * * mycron.csh | mailx -s "Subject" User@wherever.co
Note: Please refer to the bash man page to learn more on redirections (>, >>, &). You may also search for "bash redirections" online.

This last example shows how to set up a cron job to email standard output and standard error to the user. Be careful, if the standard output or standard error is large (which may happen if the job does not run as expected), this may cause the mail daemon to have problems delivering the email, which fills up /var on the node and may then cause problems with the node.

Important: Compute/memory intensive work should not be run from cron. Instead, the cron job should submit a SLURM job. For batch jobs submitted via cron, you will first need to source /etc/profile to define appropriate bash environment variables before issuing the job submission: 0 1 * * * . /etc/profile ; sbatch myjob.sh 1>> FULLPATH/submit.out 2>&1