Forum Moderators: bakedjake

Message Too Old, No Replies

crontab line not working...

problem executing a crontab script

         

mikejson

9:29 pm on Nov 27, 2003 (gmt 0)

10+ Year Member



I'm tryin to execute a php script on a cronjob and it won't execute. I was told on this forum that you can execute a php script as long as there is a php interpter on the system which there is.

Anyone have any ideas?

I don't really want to make this into a unix script simply for the fact that it does alot of work and it would take me at least a day to convert the php to unix.....

wruk999

9:45 pm on Nov 27, 2003 (gmt 0)

10+ Year Member



Hi mikejson,

From a previous thread, i wrote the following:
[webmasterworld.com...]

To achieve this, there are two ways - call the file through the php binary - like you are trying to do (I could not get it to work this way on my server)

OR

as I have done, create a shell script, with the command:

lynx -dump [website.co.uk...]

And then in the cron, simply put:

1 * * * * /path/to/shell/file/shell.sh
31 * * * * /path/to/shell/file/shell.sh

I think this will be the easiest way for you - but this will only work if the lynx browser is installed on your server.
Try from a command prompt:
whereis lynx
and see what response you receive

wruk9999

jatar_k

9:45 pm on Nov 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what exactly is happening? for us our crontab looks like this

# minutes hour day of month month of year day of week (0-6; the 0 refers to Sunday) command

#this one is 9:31 am, any day of month, any month of year, on monday->Friday
# This is Sun specific cron, too

31 9 * * 1,2,3,4,5 /usr/local/bin/php /path/to/your/phpfile.php &

mikejson

8:43 pm on Nov 28, 2003 (gmt 0)

10+ Year Member



I'll try what was suggested.

When calling the php script directly in the cron, I get an email stating the cron cannot execute the file.

I'm a newbie to crons and unix environment(besides navigating and editing files).

mikejson

8:52 pm on Nov 28, 2003 (gmt 0)

10+ Year Member



Ok I implemented it using the shell to call the php script through lynx(which was on our system).

I didn't set it to run right away, I'm not in a rush toget it working, I have an option from our admin section of the website to execute the script on demand anyway... Just tryin to make it easier for people.

Josk

10:51 am on Dec 1, 2003 (gmt 0)

10+ Year Member



> When calling the php script directly in the cron, I get an
> email stating the cron cannot execute the file.

Have you made the file exuecutable?

man chmod

mikejson

3:26 pm on Dec 1, 2003 (gmt 0)

10+ Year Member



trying it again... not working yet.

Could someone place an exact cron line calling a .sh?

dvduval

3:50 pm on Dec 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you need is a lynx command:

31 9 * * 1,2,3,4,5 /usr/bin/lynx [mysite.com...]

mikejson

7:25 pm on Dec 1, 2003 (gmt 0)

10+ Year Member



thanks, I'll try that and see what happens...

mikejson

2:00 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



Ok here is what came up now...

Your "cron" job on bolt
/usr/local/bin/lynx [mysite.com...]

produced the following output:

<" terminal.'t know anything about your "ÿ$

Your Terminal type is unknown!

Enter a terminal type: [vt100]
<ERMINAL TYPE IS SET TO ÿ$

That was the email exactly...
here is my cron line

0 1 * * 1-5 /usr/local/bin/lynx [mysite.com...]

It's all on one line if it doesn't come up formatted correctly...

when I $whereis lynx
it says /usr/local/bin/ is the path to it so...

Sharper

2:16 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



The shell your crontab runs things as is not necessarily the same shell (sh, csh, ksh, bash, etc...) you get when you login.

Consequently, it sounds like the cronjob you are running is not getting a shell environment that includes "normal" startup stuff like paths and terminal settings. Paths can be gotten around by always specifying the full path, like you've done, but some programs (typically normally interactive ones like vi or lynx) require a terminal setting

So, depending on what the default shell is for the system you are on, you either need to

1. Create an appropriate .cshrc or .profile, probably whichever one you don't currently use.

2. Set the variables you need in a shell script you run from the crontab, presumably running the lynx command or whatever afterwards from that script.

mikejson

7:40 pm on Dec 2, 2003 (gmt 0)

10+ Year Member



Right over my head, but I'll start the "man" searches... see what I can do.