| Knowledgebase Home | Glossary | Favorites |
| Create a scheduled job with cron | ||||||||||
Prerequisites:Connecting to your Container via SSH Related Articles:Syncing files between multiple contianers.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. Learn more. To edit what jobs are scheduled, first SSH to your container, then run: 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 /home/stacys/sites/stacyssite.com_Ver1/doc_root/cache/*To list all cronjobs in your crontab: crontab -l Note:If your cronjob is to run a php script, crond never assumes a Current Working Directory. Your cronjob needs to change directories to the location of the script before running if the cron script creates a relative include path. An example of how to run a cronjob which calls a php script would be as follows: 30 0 * * * * cd /home/username/sites/www.site.com_ver1/doc_root/cron/ && /usr/bin/php cronscript.php By default, any error messages are logged in /var/log/messages |
| Visitor Comments |
|
| Related Articles |
| No related articles were found. |
| Attachments |
| No attachments were found. |