// Using Cron on Discover
Cron is available on the host discover-cron which is an alias for the one Discover login node that runs cron. 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.
Once logged into the Discover cluster:
$ ssh discover-cron
To acccess the crontab, use the following command:
$ crontab -e
This allow you to edit your crontab. Cron is run using a bash environment only. Users are recommended to refer to the man pages for more information on using bash scripts. To access the bash man pages, use:
Following is an example of crontabs:
-------------- 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 to be executed
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 man page to learn more about redirection(>, >>, &). The man pages for bash can be accessed using "man bash".
The last two examples show how to set up a cron job to email standard output and standard error to the user. Be careful, however, 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 cause problems with the node.
Note: (Updated after Slurm transition) 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, i.e.,
0 1 * * * . /etc/profile ; sbatch myjob.sh 1>> FULLPATH/submit.out 2>&1