Cron Troubles

Cron Troubles

Posted by: KickMeElmo
Posted on: 2007-12-09 16:30:00

I'm attempting to run a crontab, but I get an error from crontab every hour claiming permission has been denied for the lock and the script does not run. This is how I phrased it:

/usr/local/php5/bin/php
/home/username/domain/scripts/script.php

I tried adding the hidden directory the username actually lies in, adding a semicolon, etc., but I can't find what's wrong. Any ideas?

Oh, and the email is as follows:

From: Cron Daemon <root@server.dreamhost.com>

Subject: Cron <username@server> /usr/local/bin/setlock -n /tmp/cronlock.1581374.13951 sh -c $'/usr/local/php5/bin/php 12/home/username/domain/scripts/script.php'

Body:
sh: line 2: /home/username/domain/scripts/script.php: Permission denied

Edited for privacy of course.

Re: Cron Troubles

Posted by: sdayman
Posted on: 2007-12-09 16:55:00

It looks to me that you have a linefeed in your crontab entry, just like it is in the post. It's supposed to be on the same line. The output even shows the /012, which is a linefeed.

First, get rid of the linefeed and see if that helps. While you're waiting, go to the command line and type: crontab -l (that's a small L)
Then cut and paste the command portion back into the command line and see if it works.

-Scott

Re: Cron Troubles

Posted by: vicm3
Posted on: 2007-12-09 17:10:00

maybe you need to give to your script.php a chmod u+x script.php


Re: Cron Troubles

Posted by: KickMeElmo
Posted on: 2007-12-09 17:14:00

I tried changing it to /dh/cgi-system/php5.cgi instead of /usr/local/php5/bin/php and got this added to the email response:

X-Powered-By: PHP/5.2.3
Content-type: text/html

I'm removing the linefeed and leaving the new location. We'll see what happens.

crontab -l returns this:

@hourly /usr/local/bin/setlock -n /tmp/cronlock.1581374.13951 sh -c $'/dh/cgi-system/php5.cgi 12/home/username/domain/scripts/script.php'

Re: Cron Troubles

Posted by: KickMeElmo
Posted on: 2007-12-09 17:20:00

Feeling dumb here. I apparently had it set as 644, not 744. Fixed it, will respond back when it gives me my next update.

Re: Cron Troubles

Posted by: sdayman
Posted on: 2007-12-09 17:23:00

.php scripts don't have to be executable; just readable. Only the 'php' binary needs to be x, which it is.

Did you create the cronjob in the panel? The setlock portion of the command seems odd. Maybe it'll work. Looking at the crontab -l, it still shows the 12 part. The mail response shows that php ran, but perhaps the rest got ignored due to the linefeed.

If *I* created that cronjob via the 'crontab -e' command, mine would have looked like:
0 * * * * /dh/cgi-system/php5.cgi /home/username/domain/scripts/script.php




-Scott

Re: Cron Troubles

Posted by: KickMeElmo
Posted on: 2007-12-09 17:31:00

It was created through the panel. Admittedly due to laziness.

Re: Cron Troubles

Posted by: KickMeElmo
Posted on: 2007-12-09 18:03:00

FIXED! It works now. Thanks everyone.
It was that it needed to be executable. Why, don't ask me. Nevertheless, that ended up being the problem.

Re: Cron Troubles

Posted by: askapache
Posted on: 2007-12-10 21:59:00

I don't understand why people use the interpreter with a shebang like that.

my crontab executes php the way php is meant to be executed (on DH at least)..

wget --spider http://domain.com/scripts/script.php


AskApache Web Development Blog

Tags: hidden directorycrontabscript phpdaemonemailscripts