Linux Basics: Scheduling Tasks Using CronApril 17th, 2008 · No Comments
The service in charge of executing these commands is called CRON. The configuration containing the list of called a CRONTAB.
How To Manage Scheduled Tasks On A Dedicated ServerIf you have a shared hosting account, you can skip to How To Manage Cron Jobs With cPanel. If you have a root access to your server, you can manage the crontab from command line. The crontab file is usually located in /etc/crontab. Let’s look at the structure of the crontab file:
A crontab may contain multiple lines like the above. Each of the first five fields may be either an asterisk (*) or a numeric value. From left to right, here are what these fields represent:
An asterisk means every [ ... ] like every minute, every hour, every day of the month, etc. Here are a few examples to help you understand better: Scheduling A Task To Execute Once A Year This would execute a script named backup.sh on December 1st at midnight:
Scheduling A Task To Run Once Every 24 Hours To set a daily task to run at 1am, you could use:
Scheduling A Monthly Task To run a script on the fifth of every month at 11pm, you could use:
Scheduling A Weekly Task To setup a weekly task to run each Saturday at 6:30 am:
But there is an easier way to manage cron jobs. In the /etc/ folder you will find four cron-related subfolders:
So for example, if you wanted to run a shell script on a daily basis, you could just create it in /etc/cron.daily and set its permission to 0755 (chmod 0755 filename). If you don’t find these folders in /etc, simply issue this command:
And to find out when the scripts from these folders are scheduled to be executed, refer to the /etc/crontab file. How To Manage Cron Jobs With cPanel
To manage the scheduled tasks from within cPanel, click on the Cron Jobs icon. You will be then be offered to use the standard or advanced interface. From the standard interface, you could setup a task to rub backup.sh every day at 3AM:
And this is how you would do the same thing from the advanced interface:
Things To Be Careful AboutThere are a few things you want to look out for when you schedule an automated task:
And if you’re unsure about what you’re doing, it always best to get support from your hosting provider! Related Posts |
Popular PostsLatest PostsLatest Deals & Coupons
Recent Comments
Recent WebmastersTag Cloud
1and1
apache
centos
cheap web hosting
control panel
coupon code
coupons
coupons codes
cpanel
dreamhost
godaddy
godaddy vs 1and1
green web hosting
hostdime
hostgator
hostpapa
iis
inmotion hosting
knownhost
linux
mysql
openads
openx
php
reseller hosting
security
shared hosting
system administration
vps
web hosting
web hosting comparison
Web Hosting Comparisons
whm
windows
windows 2008
|
|||||||||
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment