Cron Job not working for me

coolgk

New member
Joined
Sep 23, 2008
Messages
2
I want to run my script every minute for testing cron job, but it doesnt work.

*/1 * * * * /home/express/cron_csv

same command works if i run it from SSH command line


in cron_csv i have one line command

Code:
php public_html/csv/csv.php

anyone can help?
 
Couldn't you just run the code straight from the cron?

Code:
*/1 * * * * php /full/path/to/public_html/csv/csv.php
 
What's the output of the command when you type it into the shell?

Also wouldn't you need to use the php -f argument?
 
You need to check your php script to make sure that its working fine. Keep an eye on includes or requires especially when running a php script from a command line or as a cron job.

Also do what Rich-Boy suggested

*/1 * * * * php /full/path/to/public_html/csv/csv.php
 
Does your system automatically reads the crontab file you changed?
or you have to run something like crontab /whereyourcrontabfileis/username ?
 
You also might need the full path to php.

Couldn't you just run the code straight from the cron?

because it is not working for me so i tried to put command in a file.

If it doesn't work from the cron command line then putting it in a file is not going work either.
 
I have this issue too, just realised mine aint executing at the specific time :( ..... Where do the crons save to to get executed, not /etc/crontab I presume as theres only system crons in there......
/usr/local/bin/php /home/xxxxxxxxxx/domains/xxxxxxxxx.co.uk/public_html/cron/cron.php >/dev/null 2>&1
I'm guessing thats correct?

EDIT:

Found it
1=0 0 * * * /usr/local/bin/php /home/xxxxxxxxxx/domains/xxxxxxxxx.co.uk/public_html/cron/cron.php >/dev/null 2>&1
which should run at midnight right?

It executes via shell ok, so its not a php code issue.

Another note, the errortaskq and cron logs are blank......if that helps.

Another interesting find:
Compiled on Debian 3.1
Server Version 1.32.2
Current Available Version 1.323000
Last Updated Mon Jul 14 07:16:06 2008
Isn't it meant to check and update automatically?

Any ideas?
 
Last edited:
You may have found the program's location, but you didn't find the file that runs it. The contents of public_html is entirely user defined; you can put anything in there, including cron jobs (though I don't see why you'd put a cron job in public space. I'd recommend putting it at the same level as public_html, not inside it.

To get the cron to run you set it up in the Control Panel; under advanced features you should find a reference to cronjobs.

If you don't, and you don't own the server, then you need to contact your hoting provider; whether or not a hosting company allows users to run cronjobs is up to the hosting provider. Some do not, and some require a request.

If you own the server or have shell access you can also (if your username isn't listed in the /etc/cron.deny file) find or create a user cronjob; from the shell, as the user or as root:
Code:
$ crontab -e USERNMAE
where USERNAME is replaced by the login username.

Then use your system default editor (hopefully if you're using the shell you know what it is and how to use it), enter a cronjob in the proper format. If you don't know the proper format you can learn it:
Code:
$ man 5 crontab
Do NOT just use the location/name of the php file, that won't work. You must start the command with the full path to your php interpreter followed by a space and then the full path to the program you want to run.

The following is only an example; on my linux desktop machine it would run a program I put into my personal home directory top level, test.php, at 4:01 am on the first day of every month:
Code:
01 04 1 * * /usr/local/bin/php /home/jeff/test.php

Note that while you can find the crontab files in /var/spool/cron you should NOT edit them there; editing them there will NOT enable them to run.

Jeff
 
Turns out crons are executed +1 hour after (see my other thread), but the DA system crons (tally, etc) execute at the right time....... Weird!

No-one I asked knows why this is :confused:
 
Back
Top