On Jan 8, 2004, at 9:07 AM, jbv wrote:


Hi folks,

I will have MC (or Rev) CGI running on a Linux server
with Apache.
I need to trigger a script at fixed times (say every 24 hrs)
and don't see any other solution than somehow configuring
the server to do it.

[on-list, because I think this kind of thing is likely to be useful to other Rev programmers. But I am no guru.]


I would log into the Linux server via secure shell (ssh) and setup a crontab script (see below).

But if you don't have shell account access on the server, then you could setup a CGI script that can be started by a HTTP URL, and then make some utility to periodically hit that URL from another computer, to do the work as a side effect. The drawback about that approach is that often the a server config will put time, memory or cpu limits on a CGI script.

Instead, on Unix, including Linux and Mac OS X, the tool for running stuff at periodically is called "crontab". Try these commands:

man crontab
man 5 crontab
crontab -l
crontab -e
export EDITOR=/usr/local/bin/youreditor
crontab -e

crontab -e puts you into the vi editor, by default. So you might want to set the EDITOR environment variable.

Here is a crontab I use to entry to run every night to download a file from another server:

59 1 * * * cd ~/Mindlube/mysql-dumps && curl -O ftp://alexr:[EMAIL PROTECTED]/mysql.dump.gz

Notice the first 5 fields are time slots, and the rest of the line is a shell command. If the command is long, you can put it into a shell script file and just call it like ~/path/to/shell-script.sh

Unix uses shell scripting a lot, and crontab is a good chance to learn it.

Alex Rice <[EMAIL PROTECTED]> | Mindlube Software | <http://mindlube.com>

what a waste of thumbs that are opposable
to make machines that are disposable  -Ani DiFranco

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to