How To Set Up Cron Jobs In Lnix
CRONTAB
What is Crontab?
Crontab is a file which contains the schedule of cron entries to be run and at specified times.
Crontab Commands
export EDITOR=vi ;to specify a editor to open crontab file.
- crontab -e Edit crontab file, or create one if it doesn’t already exist.
- crontab -l crontab list of cronjobs , display crontab file contents.
- crontab -r Remove your crontab file.
- crontab -v Display the last time you edited your crontab file.
Crontab Examples
A line in crontab file like below removes the tmp files from /home/appsolworld/tmp each day at 6:30 PM.
30 18 * * * rm /home/appsolworld/tmp/*
Crontab every hour
cron every hour to run at 15 minute of an hour..
15 * * * * rm /home/someuser/tmp/*
Crontab every minute
To run cron every minute keep the minutes field as * , as minute changes to new minute cron will be executed every minute. if you want to run it continuously every hour then the hour field also needs to have value of * .
* * * * * rm /home/appsolworld/tmp/*
if you want to run a script every minute at specific hour, change the value of hour field to specific value such as 11th hour.
* 11 * * * rm /home/appsolworld/tmp/*
Comments
Post a Comment