Web Hosting Talk







View Full Version : Cron job command to run a script


macfan
07-18-2006, 05:11 PM
I'm new to cron job (and not too technical), and searched for documentation and forum topics, but unfortunately didn't find the answer to my question. Maybe someone can help me.

I have a script at mydomain.com/cgi-bin/directory/somescript.cgi that I'd like to run once a day. My webhost allows me to run a cron job, with a nice looking window with the text fields 'Minute', 'Hour', Day', 'Month' and 'Weekday'. That's the part I understand.

Then there is the 'Command' text field. I'm not sure what to put there. Is it just the URL, or do I need to type something else there? The URL doesn't seem to work so I don't know which command to type.

If anyone can help me, I'd appreciate it very much!

Thanks,
Marco

[IG]Chris
07-18-2006, 06:27 PM
Log into SSH then type crontab -e That will log you into your cron editor.

Then you need to schedule it, you can do this by doing:

0 0 * * * Adding that will run it once per day, so for example if I wanted to output the output of ls I could use:

0 0 ** * ls > ls.txt

Hope this helps. Its pretty brief and if you dnot get it I can explain in more detail.

macfan
07-19-2006, 03:33 AM
Hi Chris,

Thanks for your reply!
I understand the scheduled time part, it's just the command line that I have problems with. Attached you'll see the cron job window of my webhost. I don't know how SSH works.

Marco

ummi
07-19-2006, 04:40 AM
in command type FULL path to your script like /home/user_name/domains/mydomain.com/public_html/scripts/script.cgi

[IG]Chris (http://webhostingtalk.com/member.php?u=151444) -> i dont thin that @macfan has SSH access;)

macfan
07-19-2006, 07:20 AM
Hi techson,

Thanks, I tried it. Unfortunately that doesn't work either.

Marco

macfan
07-20-2006, 08:49 AM
Anyone an idea?

brendandonhu
07-20-2006, 09:07 AM
For the command line, try
wget http://mydomain.com/cgi-bin/directory/somescript.cgi

ramanladhani
07-20-2006, 09:20 AM
ask them www cnelindia com

foobic
07-20-2006, 09:24 AM
If it's the host I think it is your problem might be that crond isn't running. Try this and see if the file 'crontest' appears in your home directory:
* * * * * touch /home/username/crontest
(delete it after a few minutes or you may find your mailbox flooded...)