Forum Moderators: bakedjake
I want to run a .php file called fetch.php that basically gets emails from a pop3 account and loads them into my helpdesk database.
When I log onto my managed server (linux) through SSH and navigate to the directory with the php file and type this:
php email_fetch.php
all works fine.
So, I set up a .sh file and dumped it with full permissions in my home directory on my webserver.
The .sh file is called helpdesk.sh and has this in it:
cd PN/helpdesk
php email_fetch.php
In my crontab I have this:
32 0-23/1 * * * $HOME/helpdesk.sh
The idea being that on the 32nd minute of every hour run the script.
However, nothing is happening - any ideas why? I'm sure it's obviousl to all you gurus out there but as this is my 1st attempt at crontab or shellscript...
Thanks in anticipation
However, if I do a pwd on the $HOME directory it comes up with this:
/kunden/homepages/42/d98345334/htdocs
don't know what all that is but it is a managed server after all!
The path specified in the crontab to the ,sh file is $HOME/helpdesk.sh so I think that's OK.
Do you think the shell script needs changing to include all of the above in the patch to the php script?
still no joy
If I run the above command it works though so that path is absolute and correct.
Am I missing something in the syntax? Should there be a ; or somrthing at the end of this line?
What about the syntax on the crontab line? SHould it end with a semi-colon or not at all?
Thanks again
5,10,15 * * * * /root/*.sh
Just an example...I want it to run every 5 minutes, too lazy to write out all of the minutes, but it won't launch the script file...i even tried the /root/sh *.sh and nothing still...is there a separate synatx for launching shell scripts with crontabs?
- Good practice to start your shell scripts by specifying the command interpreter on the first line - i.e. #!/bin/sh
- Cron runs with a stripped down environment and path, it may not be able to locate the php command - might need the full path to it i.e. /usr/local/bin/php
- Trapping output and error output to a file may help you see what it doesn't like:
32 0-23/1 * * * $HOME/helpdesk.sh > $HOME/tempfile.txt 2>&1
Are there any paths it may not be resolving in email_fetch.php? When a script that runs from the cmd line doesn't run from cron 99% of the time it's an environment and/or path problem.