how to set cron job in linux php

If we want to execute a script for some specific time than we need to use the Cron job . Cron job is resposible to execute a script for assign time, and It’s very easy to set the cron job in linux.

Step1:- open Command prompt and type command

crontab -e

Step2:- set the execution time , php path and file path.

2 * * * * /usr/bin/php /var/www/html/project_name/cron/mail.php

Step3:- save the file using ctrl+x

*/1 * * * * /usr/bin/php /var/cronFile.php

* is used for set the cron execution time
/usr/bin/php = php path
/var/cronFile.php = location of file path

1) * means 1 minute.
2) * means hour.
3) * means day.
4) * means month.
5) * means week.

If you have no idea your php path . Than type below command in your command prompt.

 whereis php

Leave a Reply