Forum Moderators: bakedjake

Message Too Old, No Replies

need a little info on Cron's

Just need the basics

         

mikejson

3:53 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



I just want a few questions answered if possible.

Do they have to execute a unix script?

Do they have to only execute 1 script?

Is there any prewritten scripts posted on the web?(not really cron, more Unix in general).

Basically I want to mail a file as an attachment to an off server email address. This file is just a log file, used incase something goes wrong. I want to send it as an attachment to make it more user friendly to who will be using it. I have little to no experience is writting unix scripts.

bcolflesh

4:11 pm on Sep 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do they have to execute a unix script?

You can execute almost any script - provided the scripting engine is installed on the machine.

Do they have to only execute 1 script?

Nope.

Find a mail + attachment script for a language that is installed on your box - call it with a line in your crontab, PHP ex:

0,10,20,30,40,50 * * * * /opt/apache/bin/php /export/apache/info/htdocs/stockcron.php > /dev/null

Script runs approx every 10 minutes ¦ path to PHP scripting engine ¦ path to script which updates some stock info ¦ any output sent to nowhere...

martin

4:29 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



You can also write every 10 minutes like 0-59/10.

wruk999

4:42 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



Hi mikejson,

I have done something VERY similar to what you want to achieve. I have a "stocklist" emailed to a set of users at a certain time in the morning. This list is generated, then sent by a script called via CRON.

I use PHP to send the script.

If you would like some advice, example scripts etc, please let me know :)

Cheers,
wruk999

mikejson

6:55 pm on Sep 16, 2003 (gmt 0)

10+ Year Member



Cool, I think I can write the script no problem if I can run a php script... which is installed on this machine. That was the answer I was wanting to hear HAHA.

thanks alot guys

Josk

11:31 am on Sep 17, 2003 (gmt 0)

10+ Year Member



Why write a php script. 'nix has all the tools available to do this in a shell script.

'man -k keyword' is your friend...

mikejson

1:29 pm on Sep 19, 2003 (gmt 0)

10+ Year Member



php is installed on this machine, and I know php... I don't know unix enough to be confident.

Plus, I found something else that makes me want to use it, I can put security in it, and attach it to my admin page for my website, then the dummy users I have here can run the script from clicking a link. If they ever need this info emailed to them before the cron runs.

I'm sure you can do that with php calling a unix script, but this works good for me :)

timster

3:50 pm on Sep 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When I started using CRON, I wanted to run (already written) Perl scripts -- it didn't work to run them straight from CRON.

What I did was create 1-liner Shell Scripts to run the Perl script.

I'd set up CRON to run this shell script, and the shell script would run my Perl. I bet this would work for your PHP scripts too.

The shell script looked like:

#!/bin/sh

/path/to/perlscript.pl

-----

I'm sure this was a terrible kludge, but it worked and was pretty easy. Just gotta keep track of two files now.

martin

4:14 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



You can use something like this instead:

#!/bin/sh

$*

I used this together with export QUERY_STRING="something" to emulate running a script from a CGI webserver.

timster

4:37 pm on Sep 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Martin, can you explain that a little further? What is the $* up to?

Brett_Tabke

4:40 pm on Sep 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Old info [google.com] on cron.

martin

11:50 am on Oct 5, 2003 (gmt 0)

10+ Year Member



It's all parameters passed to the script so all it does is execute the script you pass to it so you can do myscript.sh "/usr/bin/perl /home/foo/bar.pl" instead of having a shell script for every perl script you want to run from cron.

timster

4:46 pm on Oct 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Martin,

Thanks -- I see.

Sorry if I was dense. Too much Perl scripting made me think $* was just a way to pass variables.