Forum Moderators: coopster
The error is:
/home/mydir/cleanup.php: line 1:?php: No such file or directory
/home/mydir/cleanup.php: line 4: syntax error near unexpected token `'/home/mydir/mysql_connect.php''
Is the cron job not expecting php? It's reading the file and access permissions are set correctly. Confused.
Thanks for any help!
My quickest guess is you're trying to call the php script directly, like this
5 * * * * /home/mydir/cleanup.php and cron is trying to run the php file as a shell script.
If you want to call your php scripts this way, you need to let *nix know what interpreter to use. Add something like the following to the top of your php file and you should be fine
#!/path/to/php (Where /path/to/php is the full path to the php binary)
If this isn't an option, you'll need to run the php binary with your script as an argument. Your cron would look something like this
5 * * * * /path/to/php /home/mydir/cleanup.php If you have access to a command line, the command [whereis php] or the command [locate php] should help you find the php binary.
My script is writing to file and work a long time. How can I start it from cron job?