A cron job is a Linux command for scheduling
script on your server to complete repetitive tasks automatically. Scripts
executed as a cron job are typically used to modify files, databases and manage
caching.
Cron is controlled by "crontabs". There is the master file in /etc/crontab. Each user's cronjob is stored in /var/spool/cron/username directory.
Benefits of Cron
Cron is controlled by "crontabs". There is the master file in /etc/crontab. Each user's cronjob is stored in /var/spool/cron/username directory.
Benefits of Cron
·
Cron already built, and works, very reliable
·
You more easily have control over when it runs. You control the
minute, hour, day, month and weekday etc.
·
You can run many cron with difference of 15 seconds
·
You can manage cronjob from admin panel
·
Need not run manually, Schedule once will execute manually.
Install crontab
crontab -a filename
Edit the crontab
$ crontab -e
Display crontab
crontab -l
Display the last edit the crontab file
crontab -v
Remove crontab
crontab -r
Following are the syntax for cron
minute(s) hour(s) day(s) month(s) weekday(s) command(s) "Argument1" "Argument2"
1 * 3 4 5 /path/to/command
arg1 arg2
If you don't have parameter put star (*)
Description of Cron fields
Field Description
minute(0-59) The exact minute that the command sequence
executes
hour (0-23) The hour of the day that the command sequence executes
day(1-31) The day of the month that the command sequence executes
month(1-12) The month of the year that the command sequence executes
weekday(0-6) The day of the week that the command sequence executes (Sunday = 0, Monday = 1, Tuesday = 2, and so forth)
command(s) File Path Absolute path CronFile
Argument Argument (IF you want to pass an argument)
hour (0-23) The hour of the day that the command sequence executes
day(1-31) The day of the month that the command sequence executes
month(1-12) The month of the year that the command sequence executes
weekday(0-6) The day of the week that the command sequence executes (Sunday = 0, Monday = 1, Tuesday = 2, and so forth)
command(s) File Path Absolute path CronFile
Argument Argument (IF you want to pass an argument)
No comments:
Post a Comment