Feb 19, 2014

0 Setting up a cronjob











I have added my script in folder : /etc/cron.hourly/

sudo touch system_stats

To make script executable:

chmod +x system_stats



sudo crontab -e   to add job to list.

Add folowing line, to run your script every hour.

*/1 * * * *  root  /etc/cron.hourly/system_stats

Ctrl + O
Ctrl + X

To check crontab list of jobs use :
crontab –l
You should see your recently added job.

Run cronjob by hand :
run-parts /etc/cron.hourly



Special note :

! Giving your cronjob script an extension will make it invalid and result in the job not being run.

     This mean , that if your script has name :   system_stats.sh    it won’t run.





0 comments :

Post a Comment

Comment: