Cron and at Flashcards
Crontab file
/etc/crontab
- minute (0-59)
- hour (0-23)
- day of month (1-31)
- month (1-12) or jan,feb,mar
- day of week (0-6) or sun,mon…
- user-name
- command to be executed
Set up cron job
crontab -e */2 4 * * * /usr/bin/tar -czf myfile.tar.gz /home/user/important_ file1
List cron jobs
crontab -l
crontab -l -u kenny
Location of where cron job will be saved
/var/spool/cron/user_name_run_crontab -e
Remove crontab jobs
crontab -r -u kenny
Location of dirs where scripts could be run on a regular basis as if they were cron jobs
/etc/cron.hourly/
/etc/cron.dailly/
/etc/cron.weekly/
/etc/cron.monthly/
Dir contains cron scripts for entire system
/etc/cron.d/
Forbid users to create cron jobs
/etc/cron.deny
Create job with at
at now + 5 minutes
enter command
press ctrl+d
at 4:00 AM tomorrow
at -f /home/user/script.sh 10:00 AM Oct 8 2018
List at queue
atq
Remove schedule at’s job
atrm [job number]
Allow/ Deny users to run schedule a job with at
vim /etc/at.allow
add root to allow root to schedule at jobs
vim /etc/at.deny
add user to deny user to schedule at jobs