Difference between revisions of "XMission Control Panel/Server/Cron"

From XMission Wiki
Jump to: navigation, search
(Created page with "Cron enables users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. It is commonly used to automate system maintenance or administr...")
 
Line 32: Line 32:
 
crontab -l
 
crontab -l
 
</pre>
 
</pre>
 
<br><br>
 
{{:Cloud}}
 
[[Category:Cloud Hosting|Cron Jobs]]
 
[[Category:Cloud Server]]
 

Revision as of 17:45, 14 April 2016

Cron enables users to schedule jobs (commands or shell scripts) to run automatically at a certain time or date. It is commonly used to automate system maintenance or administration. Some CMS like Drupal use cron to automate some tasks.

To edit what jobs are scheduled, first SSH to your server, and enter:

crontab -e

This should open up an empty crontab if this is your first time using Cron.

Cron uses the following syntax to schedule jobs.

minute hour day month day-of-week command-line-to-execute

Some examples of proper scheduling syntax:

*/5 * * * * : Run cron every 5 minutes
* */1 * * * : Run cron every hour
* * */3 * * : Run cron every 3 days
* * * */1 * : Run cron once every month
*/5 * */3 * * : Run cron every 5 minutes, all day, every 3rd day.
30 0 * * * : Run cron at 12:30 every day

An example of a cron job which will remove all the contents of a cache directory every 3 days:

* * */3 * * rm -rf /var/www/vhosts/domain.com/http_docs/cache/*

To list all cronjobs in your crontab:

crontab -l