cron - permission denied

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

cron - permission denied

Post by s.dot »

I tried to set up my first cron job using this command

Code: Select all

0 2 * * * /home/scottttt/public_html/tasks.php
The results of this are: /bin/sh: line 1: /home/scottttt/public_html/tasks.php: Permission denied

Why am I getting this message?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

is the file executable? (I think that is what is needed...) :?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

0 2 * * * "/usr/bin/php /home/scottttt/public_html/tasks.php"
or alternatively like feyd mentioned.... try this, it's interesting to know anyway:

add this line to the VERY top line of the PHP script:

Code: Select all

#!/usr/bin/php
That should not be in PHP tags that should be all that's on the line... it's a shebang line and tell the script which program run it ;)

Then you need to make the script executable:

Code: Select all

chmod +x /path/to/php/script.php
After that, your original crontab should work :) Executing files requires the "x" permission to be set.

Note: The .php is not needed if you add the shebang to an executable script. Nice for making command line tools
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

a couple of sample entries

Code: Select all

*/30 * * * * cd /home/screwedup/web/tools; /usr/bin/php ringupdater.php > /dev/null 2>&1

5 1 * * * /usr/bin/wget http://www.example.com/tools/ringnotify.php | mail -s "ringnotify.php" me@example.com
Post Reply