I am new to cron
and I do not know how to work it and I have researched everywhere, but I am confused
I have a mysql database which is connected to php and it is on a website which is called ytable.php.
Within that php file, I have a for loop which needs running every hour in order to retrieve new information. However, I am not sure what to do in order to do this.
I know I have to write 0 * * * *
somewhere in the coding.
Most of the answers on this website tells how the * * * * *
work, but I am not interested intuit because I already understand that bit of the cron
job.
Do you either:
put the command in a text file and write <?php exec(whatevertextfile.txt) ?>
in the file itself?
OR
Everyone has been telling me to open up Terminal(Mac) and put it in crontab -e
, but I do not know what to write when I get there.
Can you not run a cron job from a php file as I find it easier to edit compared to Terminal.
Please help.
In your terminal:
#lists current jobs setup
someUser~>crontab -l
#let's you edit/create jobs
someUser~>crontab -e
Once you open the file:
* * * * * /usr/blah/hooray python someFile.py
Then hit ESC . type ":x" <-- short hand for write\\quit
It's best to setup your cronjob for a few minutes from when you create it to see it in action. You can use the >> somefile.txt to log what's going on
Try This,
You need to run a php file through cron job.
in your terminal...
user > crontab -e
0 * * * * /opt/lampp/bin/php -f /<absolute path of file>/cron_summary_sales.php
< /opt/lampp/bin/php > this is PHP path, as I use LAMPP, You use appropriate path for your PHP setup in your MAC. you also have to make sure how to run PHP from MAC terminal.
save it.
For mac, I think you should do,
0 * * * * php /<absolute path of file>/cron_summary_sales.php
OR
0 * * * * /<absolute path of dir> php cron_summary_sales.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.