PHP Developers Network
http://forums.devnetwork.net/

cron job
http://forums.devnetwork.net/viewtopic.php?f=30&t=79295
Page 1 of 1

Author:  dannyd [ Mon Feb 25, 2008 12:07 pm ]
Post subject:  cron job

I created a php script and I want it to run everyday at 10:30am. How would I make that into a cron job ?

Author:  s.dot [ Mon Feb 25, 2008 12:30 pm ]
Post subject:  Re: cron job


Author:  dannyd [ Mon Feb 25, 2008 12:34 pm ]
Post subject:  Re: cron job

Is it possible to run the cron job on the command line to test ?

So far I've added the line:

30 10 * * * /script

Instead of having this line referencing to php:

/usr/bin/php /home/me/public_html/myscript.php

will adding this line at the top be the same:

#!/usr/local/bin/php -q

Author:  marnieg [ Mon Jun 28, 2010 1:20 pm ]
Post subject:  Re: cron job

I'm having a similar problem, but here is my environment and issue.

I'm using Putty for my connection to SSH. After logging in I use the command

crontab -e which opens the editor

I put the following commands in

# email for course start alert everyday at 8 am
00 08 * * * /usr/local/bin/php /var/www/vhosts/wtionline.cc/crontasks/emailcoursealert.php

My php file is listed under my hosting directory as stated in the path.

First, my question is how do I SAVE this file and where is it placed on the hosting server?
If I want to edit it again how do I do this. I'm assuming these are all command line functions, but not familiar with linux or putty.

Author:  AbraCadaver [ Mon Jun 28, 2010 1:29 pm ]
Post subject:  Re: cron job


Author:  marnieg [ Mon Jun 28, 2010 2:49 pm ]
Post subject:  Re: cron job

When I login it says "The program included with the Debian GNU/Linux system are free software. So I tried your Ctrl o and nothing happened. Also tried the SHIFT : but just got the characters :. The Ctrl just backed up the cursor one character to the left.

I will continue to google putty and see if I find other information.

Any other suggestions welcomed.

Author:  AbraCadaver [ Mon Jun 28, 2010 2:55 pm ]
Post subject:  Re: cron job


Author:  marnieg [ Mon Jun 28, 2010 3:28 pm ]
Post subject:  Re: cron job

Yes I found figured out it was using the vi editor from my hosting company. I was able to create a file with my command and now just waiting to see if it works. I'm assuming the job is ready to run based on the Linux Server and it looks for cron jobs automatically.

Author:  marnieg [ Tue Jun 29, 2010 10:23 am ]
Post subject:  Re: cron job

My job is not executing for some reason.

I contacted my hosting company to figure out the path for the file location and used pwd to get that information. Here is my final script

0 10 * * * /homepages/41/d283671596/crontasks/emailcoursealert.php


Is there a way for me to get a notice of whether the job had errors or executed at all. This should have ran at 10 AM Central time, which is the time of my server. The php script should be sending me an email message.

This is the only line in my script file.

Author:  AbraCadaver [ Tue Jun 29, 2010 1:27 pm ]
Post subject:  Re: cron job

Well, if you are using the !#/usr/bin/php method then you need to set emailcoursealert.php to be an executable.
Syntax: [ Download ] [ Hide ]
CHMOD +x emailcoursealert.php


For the mail issue, add this to the top of the crontab:
Syntax: [ Download ] [ Hide ]
MAILTO=you@example.com

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/