0

I read on various articles on google that a 'cron job' is used to schedule a task to run periodically on a server. I'm in a situation where I need to schedule a script to run nightly. The script would probably be written in php and update a MySQL database. Is a 'cron job' the ideal way to accomplish this? Thanks for any information

:)

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rch1231
0

Update: I've accomplished the above by typing crontab -e into a command prompt on the server, then modifying the file with

59 23 * * * wget http://distillery.bah.com/~iteam1/RunScriptNightly.php

Which should run at 11:59 pm each night. It has the side effect of causing a log to be created on the server (when I type 'ls' command, it says I received new mail, and it says the directory and filename in which the mail is located). It also downloads the file (because that is what wget does) and drops it into a directory. To be honest, both of these things annoy me. I could run another script using cron to clean up after this mess, is that the best option?

0

This may sound obvious, but have you tried the cron without the "wget" command?
My (very limited) understanding of wget is that is is used for downloading files from the net, not running them. If you only want to run the script, you just set the cron to access it at the required time, you don't need to download it.
I am not sure about the log though as I access my crontab via a cpanel, not a commant prompt.


Zagga

1

Hello,

You should be calling the file from it's actual location instead of the web location. And the reason you are getting emails is you are not redirecting the output from the php script to somewhere. Since there is no terminal cron sends it to you in an email.

For example, the entry

10 17 * 6,7,8 1,5 /usr/bin/ps >> /tmp/psfile 2>&1

in your crontab file schedules the ps command to execute at 5:10 PM (17:10) on every Friday and Monday during June, July, and August.

When using crontab, redirect any output that is normally sent to the terminal to a file. In this example, 2>&1 redirects any error messages to the file psfile.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.