Linux Crontab Configuration
Linux cron, makes you run commands/scripts on schedule..
fields
(* * * * *)
First Field: minute
Second Field: hour
Third Field: day of the month
Forth Field: month of the year
Fifth Field: day of the week
list
List crontab entries for current user
$ crontab -l
List crontab entries for any user as root
root# crontab -u sysadm -l
edit
Edit crontab entries for current user
$ crontab -e
Edit crontab entries for any user as root
root# crontab -u sysadm -e
See which users have crontab entries as root
root# ls -al /var/spool/cron/
example 1
Run every Sunday at 3am
0 3 * * 0
example 2
Run every 15 mins on Mondays
*/15 * * * 1
example 3
Run at 3am first day of every month
0 3 1 * *
example 4
Run every hour at 00
0 * * * *
example 5
Run every minute
* * * * *
If /etc/cron.allow file exists and contains users, /etc/cron.deny existance dies not matter.
Users in /etc/cron.allow file will be permitted.
If /etc/at.allow file exists and contains users, /etc/at.deny existance dies not matter.
Users in /etc/at.allow file will be permitted.
if /etc/cron.allow file file exists but empty, no users will be permitted.
if /etc/at.allow file file exists but empty, no users will be permitted.
if /etc/cron.allow file does not exits and if /etc/cron.deny file contains users, those users will be denied.
if /etc/at.allow file does not exits and if /etc/at.deny file contains users, those users will be denied.
if /etc/cron.allow file does not exits and /etc/cron.deny file empty, all users will be permitted.
if /etc/at.allow file does not exits and /etc/at.deny file empty, all users will be permitted.
example 6
Run script.sh script two hours later
$ at -f script.sh now+2 hours
example 7
Run script.sh script at 5/15/18 3am
$ at -f script.sh 3:00am 5/15/18
atq
Query at jobs
$ atq -l
atrm
Remote at job number 5
$ atrm 5