Search Our Database

CronJob and Example

Last updated on |
by

Introduction

The cron command line is a job scheduler utility on Unix-like OS, such as Linux. You may use cron to setup a service to run on fixed time periodically, and it called CronJob. It can be setup from minutes to hours to daily, weekly, monthly, or a custom interval.

 

Examples

Executing the script using PHP from Crontab

The following script executes the PHP script every 10 minutes.

*/10 * * * * /usr/local/bin/php -q /home/username/domains/domain.com/public_html/pathtoscript/script.php > /dev/null 2>&1

 

Executing the script using wget

The script below calls the URL of the script using wget every 5 minutes.

*/5 * * * * /home/username/wget --output-document=/dev/null http://domain.com/pathtoscript/script.php > /dev/null 2>&1

Running the script using cURL

The following script executes the PHP script by calling the URL using CURL every 5 minutes.

*/5 * * * * /home/username/curl –output-document=/dev/null http://domain.com/pathtoscript/script.php > /dev/null 2>&1

 

For more information regarding CronJob timings, crontab.guru is an excellent resource for checking cron schedule expressions.

 

For additional assistance or if you encounter any issues, please contact our support team at support@ipserverone.com.