Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing a PHP script with a CRON Job [closed]

Tags:

I would like to run a PHP script every day at midnight. After research on how to do this, it appears that the best way to achieve this is to use a CRON job.

If my php script was located at http://example.com/scripts/scriptExample.php, can somebody be able to show the most simple example of what this CRON command would look like?

I have looked through numerous posts but I cannot find a simple enough example for me to learn and build upon.

like image 412
djnetherton Avatar asked Apr 22 '13 10:04

djnetherton


People also ask

Do cron jobs run when terminal is closed?

Show activity on this post. When your computer is shut down (or the cron daemon is otherwise not running), cron jobs will not be started. If you have jobs that you would like to run after the fact during those times when the computer is shut down, use anacron.

Do cron jobs run when computer off?

cron jobs run while the computer is on & not sleeping, so it will run in situations 1 and 2. If the computer is off or asleep at the job's scheduled time, it does not do any sort of catch-up run later when the computer restarts/wakes up; therefore, it will not run in situation 3.


1 Answers

Crontab needs the full path on your server.

0 0 * * * php /var/www/vhosts/domain.com/httpdocs/scripts/example.php 

This will execute every day at midnight.

like image 195
karmafunk Avatar answered Oct 04 '22 20:10

karmafunk