Cron tab help

Status
Not open for further replies.

Mike

New member
Jun 27, 2006
6,777
116
0
51
On the firing line
Okay, I'm about to pull my freakin' hair out. What is the code I need to put in the cron job manager to get it to just execute a simple php script?

In other words, if I wanted to have it run a script at http://www.some-random-website.tld/directory/php-script-to-run.php?option=1234565
every 6 hours, what do I do?

Here's what I've got so far and it doesn't work:

Code:
* */6 * * * /usr/bin/ftp http://www.my-site.com/directory/directory2/cron.php?option=123456798
 


1) you're doing it every minute for every hour that's divisible by 6 :) 6:01, 6:02, 6:03...

0 */6 * * * is what you want

As far as the command line goes, site5 suggests this:

GET http://yourdomain.com/path_to_file/cgi-bin/file.cgi > /dev/null

I don't know if that'll work for you, you might check for wget... I use this on my local machine to get the webpage and then delete them (it's in a separate file)

Code:
#!/bin/bash
CMD="/usr/bin/wget --delete-after --wait=10 --random-wait --user-agent=\"Mozilla/4.0\" --referer=http://www.google.com"

$CMD "http://(site to get)"
$CMD "http://pingomatic.com/ping/(blahblahblah)

Okay, I'm about to pull my freakin' hair out. What is the code I need to put in the cron job manager to get it to just execute a simple php script?

In other words, if I wanted to have it run a script at http://www.some-random-website.tld/directory/php-script-to-run.php?option=1234565
every 6 hours, what do I do?

Here's what I've got so far and it doesn't work:

Code:
* */6 * * * /usr/bin/ftp http://www.my-site.com/directory/directory2/cron.php?option=123456798
 
lol

1) change the first star in your line to a number between 0 and 59 inclusive or you'll go nuts.

2) change your /usr/bin/ftp in your line to GET ( no path) and put >/dev/null on the end.

3) if that doesn't work, see if your host has wget on the server and write a shell script to wget the file you want wgot ( and delete the file after ) and put THAT in the cron instead of the GET ( your script here ) > /dev/null line.
 
No worries.

Well, I made the changes, set the time to every minute and this is the response I got:

Code:
/bin/sh: /usr/bin/GET: Permission denied

Does that mean anything to anyone?
 
what are you trying to do? download a file? if so just do it with PHP as I know you know that then run your script with the cron via cli if it's local

1 */6 * * * php -q /my/script/full/location/script.php

or

1 */5 * * * wget http://mylocation.com/script.php?vars

if you don't have to go through wget don't. As there's no need to use apache with php calls, I've had it crash apache if you're doing enough threads that way much better to just call via the command line.
 
It's like your host has changed the permissions on GET so it cannot be executed like that.

Try the other varients, including wget/lwp-download/curl

Also make sure you change your cron line again as you want it every 6 hours not every minute at hours dividable by 6.

These are some other varients to try,

Code:
0 */6 * * * /usr/bin/wget http://www.my-site.com/directory/directory2/cron.php?option=123456798
0 */6 * * * /usr/bin/curl http://www.my-site.com/directory/directory2/cron.php?option=123456798
0 */6 * * * /usr/bin/lwp-download http://www.my-site.com/directory/directory2/cron.php?option=123456798
 
I've installed WP-O-Matic on a blog, and you can either update it manually by going into admin and clicking "Fetch" or automatically by creating a cron job to call the script.

So, all I need to do, is set a cron that will activate the script.

I tried the php command, it didn't like that either. This is on Hostgator, maybe I need to call them.
 
Status
Not open for further replies.