Invalid crontab

Invalid crontab

Posted by: section31
Posted on: 2006-04-11 16:39:00

Hi, i just tried to setup my first cronjob and I failed miserably.
My Goal: To run a php script every 30 minutes.
My attempt was as folows.

1. vi foo
MAILTO: myemailaddress
*/30 * * * * php /home/myusername/mydomain.com/script.php

# install cron
2. crontab foo


Now I get an email stating this.

In reply to:


/bin/sh: line 1: php: command not found


I used this cron on my previous shared server without a problem. I also tried running it as a shell script whatever by putting #!/usr/local/bin/php -q on top of my php script, chmodding it to 755 and then just doing */30 * * * * /fullpath/script.php, but that doesn't work either.

2 questions.
1. How can I get this working?
2. If i didn't put MAILTO on the cron, what email does the system to use and how do I change or modify that?

Oh, and running php script.php from the shell runs perfect....Must have something to do with this server clustering which confuses the hell out of me.

Edited by section31 on 04/11/06 04:58 PM (server time).

Re: Invalid crontab

Posted by: norm1037
Posted on: 2006-04-12 10:21:00

Make sure you have a blank line after the crontab line in your text file foo. I.E. Press return twice.

You may want to try the full path for php
/usr/local/bin/php




Re: Invalid crontab

Posted by: section31
Posted on: 2006-04-12 12:27:00

Excellent, that was it. Thanks norm.

Do you happen to know the answer to my other question? About where I can find and modify my email address for my *nix user account?

Re: Invalid crontab

Posted by: norm1037
Posted on: 2006-04-12 14:52:00

I am not too sure what you mean here. But if you mean the username that you use to login, for example with ssh, to the account then that is fixed.


Re: Invalid crontab

Posted by: matttail
Posted on: 2006-04-13 21:06:00

If you don't specify a mailto address, messages will be sent to that user's maildir. So, if you set up an E-mail address in conjunction with the user (through the panel) who's got the cronjobs then you'll recieve the messages normally. If there's no E-mail address set up with the user, it will still be delivered to the maildir, you'll just have to use SSH to access it.

I think that you can specify any dreamhost address as the mailto address as well....



-Matttail

Re: Invalid crontab

Posted by: matthiasxc
Posted on: 2006-04-15 19:29:00

I'm having the exact same problem and (what with me being very new to shell commands) I have no idea what it means to use the full path.. /usr/local/bin/php

My crontab currently looks like:

*/30 * * * * php /home/username/userdomain/folder/script.php

Does this mean that it should look like this?

*/30 * * * * php /username/local/bin/php/script.php



Re: Invalid crontab

Posted by: norm1037
Posted on: 2006-04-16 03:49:00

Instead of:-

*/30 * * * * php /home/username/userdomain/folder/script.php

try

*/30 * * * * /usr/local/bin/php /home/username/userdomain/folder/script.php

(all on one line with at least one space between /usr/local/bin/php and /home/username/userdomain/folder/script.php)




php is the 'executable' part and cron needs to know that it is in the folder /usr/local/bin/ which is the 'path'.

So when a program asks for the full path it means to add the exact route to the location of the program or script on a particular computer.



Tags: script phpphp scriptemailmydomainshell scriptcroncrontabfoomailtorunningusrhell