How do I create configure a CRON Job using PHP
If you want to run the jobs as a root user use sudo bash (or change the user )
Open the cron job tab by using the following command
crontab -e
command editor will show existing cron job configurations as shown above
CRON Job Format
1 2 3 4 5 /path/to/command arg1 arg2
1: Minute (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command - Script or command name to schedule
Example:
The following example shows how to create a CRON job that executes a PHP file every 15 minutes and writes out put to a log file
0,15,30,45 * * * * php -f /var/www/services/process_contact_us_submissions.php > /var/www/services/process_contact_us_submissions.log
Explanation:
1. 0,15,30,45 - run at the following minutes of the hour 0,15,30,45
2. * - runs every hour
3. * - runs every day
4. * - runs every month
5. * - runs every day of the week
php command : php -f /var/www/services/process_contact_us_submissions.php > /var/www/services/process_contact_us_submissions.log
do !wq to save the cron tab.
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command - Script or command name to schedule
Example:
The following example shows how to create a CRON job that executes a PHP file every 15 minutes and writes out put to a log file
0,15,30,45 * * * * php -f /var/www/services/process_contact_us_submissions.php > /var/www/services/process_contact_us_submissions.log
Explanation:
1. 0,15,30,45 - run at the following minutes of the hour 0,15,30,45
2. * - runs every hour
3. * - runs every day
4. * - runs every month
5. * - runs every day of the week
php command : php -f /var/www/services/process_contact_us_submissions.php > /var/www/services/process_contact_us_submissions.log
do !wq to save the cron tab.

No comments:
Post a Comment