Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

run a chron job for a PHP document

I need to run a PHP document once a day at a particular time, I would think it would have to be a cron job that I would have to set, however I have no Idea how it works would someone be willing to help me out?
0
jtrudeau
Asked:
jtrudeau
  • 9
  • 7
1 Solution
 
bozoka45Commented:
Are you running an Apache server? Are you able to use Cron jobs? What time of the day do you want to run the cron job?

The code you'll want to use is: wget --delete-after http://www.mysite.com/script.php
0
 
jtrudeauAuthor Commented:
yes its apache and I have never used cron jobs before...
0
 
bozoka45Commented:
Do you have a control panel that allows you to set cron jobs? Does your host allow cron jobs?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jtrudeauAuthor Commented:
delete ??????    :(

what would I do if I wanted to run every day at 11PM
0
 
jtrudeauAuthor Commented:
its my dedicated server and the control panel I am running is Plesk, it doesnt appear to let me do all I need to do, it appears to be a on time cron job
0
 
bozoka45Commented:
The wget command stores a temporary file so that it can execute the PHP. The --delete-after command just deletes the temporary file.

Please, answer my questions so that I may help you. :) Does your host allow you to run cron jobs? Do you have a control panel or shell access?
0
 
jtrudeauAuthor Commented:
yes I can run cron jobs I have shell access and I have the control panel Plesk 7.5 reloaded
0
 
bozoka45Commented:
I'm not familiary with Plesk. Is there a section for Cron jobs?

This is the entry you'll want to add:

0 23 * * * wget --delete-after http://www.mysite.com/script.php
0
 
jtrudeauAuthor Commented:
yes there is if you have an email I could send you a print screen of the page
0
 
jtrudeauAuthor Commented:
it appears that the url to the script.php is open to the public, I CANNOT have this open to the public :(
0
 
bozoka45Commented:
There should be 6 boxes. 5 small ones and then one long one. Use the code I gave before and insert each one into one of those boxes.
0
 
jtrudeauAuthor Commented:
ok please send me an example of a cronjob that runs every Minute so I could do sometests please, and what about keeping this job/document out of reach from the public
0
 
bozoka45Commented:
So you want to run the file from a non public directory?

Read this tutorial, it explains what you'll need to do.

http://www.htmlcenter.com/tutorials/tutorials.cfm?id=155&type=PHP
0
 
bozoka45Commented:
This page explains timing of a cronjob

http://www.phpfreaks.com/tutorials/28/0.php
0
 
jtrudeauAuthor Commented:
the cron doesnt appear to be working, I put an emailing script in there to email me when the page runs, and only when I go to the page does it run, what up with that ?, Im lost please help
0
 
jtrudeauAuthor Commented:
in the phpfreaks site it gives me this as an example

0 * * * * /usr/local/bin/php /home/user/crons/cronjob.php >/dev/null

what is /dev/null

 but does not give me

wget --delete-after
0
 
jdpipeCommented:
There is no reason to use the 'wget' approach if you can use jtrudeau's example. Using the PHP script directly is better.
If you want a CRON with a nice interface you might want to look at http://sourceforge.net/projects/phpcron/
It's worth learning propert cron though.
JP
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 9
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now