cron daemon to execute scheduled commands
cron [-f] [-l][-L loglevel ]
cron is started automatically from /etc/init.d on entering multi-user runlevels. Cron searches its spool area (/var/spool/cron/crontabs) for crontab files (which are named after accounts in /etc/passwd); crontabs found are loaded into memory. Note that crontabs in this directory should not be accessed directly - the crontab command should be used to access and update them. Cron also reads /etc/crontab, which is in a slightly different format. Additionally, cron reads the files in /etc/cron.d.
|-f||stay in foreground mode, don't daemonize.|
|-l||Enable LSB compliant names for /etc/corn.d files. This setting, however, does not affect the parsing of files under /etc/cron.hourly, /etc/corn.daily, /etc/cron.weekly or /etc/cron.monthly .|
|-L loglevel||Tell cron what to log about jobs as the sum of the following values:
List Scheduled Cron Jobs for a particular user
# cron -u nubo -l
output: no cron for nubo
System Wide Cron Schedule:
System administrator can use predefine cron directory as shown below. /etc/cron.d /etc/cron.daily /etc/cron.hourly /etc/cron.monthly /etc/cron.weekly
List Crontab Entries
# cron -l
output: 00 10 * * * /bin/ls >/ls.txt
To remove cron entry:
crontab -i -r
-i is for interactive , it will prompt the user before deleting a job
output: cron: really delete root's cron?
To scedule a job for specific time:
The below jobs delete empty files and directory from /tmp at 12:30 am daily.
You need to mention user name to perform crontab command. In below example root user is performing cron job.
# crontab -e
30 0 * * * root find /tmp -type f -empty -delete
Special Strings for Common Schedule
|@reboot||Command will run when the system reboot.|
|@daily||Once per day or may use @midnight.|
|@weekly||Once per week.|
|@yearly||Once per year. we can use @annually keyword also.|