Re: need help on shell programming



Why is it not the 'best' idea? Infinite loops can be used to your advantage. It's already been remarked that cron will not work because it is fixed-frequency. That means OP will have to start maintaining state via files to avoid race conditions.

An infinite while;do;done construct can be interrupted by a SIGINT anyways. A well-constructed shell script will trap this signal and clean up whatever dirt it's left behind for finally dying. The while [ 1 -eq 1 ]; answer is semantically correct, but using while true; looks nicer.

Raphael Faria wrote:

i dont think that script with an eternal loop is the best ideia. If u want keep this script running for a long time ( even when ur user is loged out, u will need a screen desatached [ screen ^a ^d]). My advice will be that u make this script and set a rule at ur crontab for every min:

#crontab -e

(put this line if u need taht script to run every min)
* * * * * ./path/script


hope that helps u,



2009/3/1 Olaf Reitmaier Veracierta <olafrv@xxxxxxxxx <mailto:olafrv@xxxxxxxxx>>

while [ 1 -eq 1 ]; then
<PUT HERE YOUR COMMAND>
sleep 60
done

Boyd Stephen Smith Jr. wrote:

On Thursday 26 February 2009 18:35:01 Mike Castle wrote:

On Thu, Feb 26, 2009 at 4:29 PM, Michael Pobega
<pobega@xxxxxxxxx <mailto:pobega@xxxxxxxxx>> wrote:

On Thu, Feb 26, 2009 at 04:54:28PM -0500, Long Wind wrote:

I want a script.
The script run a command, wait one minute,
then run the command again, wait one minute again
... again and again ...

Sounds like a job for Cron!

It depends on how long the job takes, and what the
requirements are.

They did seem to imply they want to wait 60 seconds
between the end of
one run to the start of the next one, as opposed to
running every 60
seconds regardless.


The OP says they want fixed-delay. Cron is for
fixed-frequency. A script that schedules itself as an "at"
job as it's last command is another way to handle fixed-delay.

If the job takes 45 seconds, it could be a pretty
substantial semantic
difference.


Yep.


-- ----------------------------------------------------------------------
"You don't know where your shadow will fall",
Somebody.-
----------------------------------------------------------------------
Ing. Olaf Reitmaier Veracierta <olafrv@xxxxxxxxx
<mailto:olafrv@xxxxxxxxx>>
----------------------------------------------------------------------
http://olafrv.googlepages.com (Personal Webpage)
http://olafrv.blogspot.com (Technical Blog)
----------------------------------------------------------------------


-- To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
<mailto:debian-user-REQUEST@xxxxxxxxxxxxxxxx> with a subject of
"unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
<mailto:listmaster@xxxxxxxxxxxxxxxx>




--
Raphael Ottoni S M de Faria


There is no spoon...


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: Nmon scheduling question
    ... command ran first then in the script is the ps and kill command so it ... Vince this is a great script. ... Cron Job with pid: 135238 Failed ...
    (AIX-L)
  • SUMMARY: cron entry: nth day of every month?
    ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
    (Tru64-UNIX-Managers)
  • Script wont run from cron
    ... the command line, but the same script fails when running from cron. ... The /bin/sh script runs, but when it goes to fire up the indexing process, ... set, id and limits. ...
    (freebsd-questions)
  • Re: Cron Job
    ... If you mean the computer itself, put that command ... The standard 'cron' runs jobs at a specific time/date. ... Init or @reboot run jobs when ... Sunday night at 02:00) then copy the script and cron entry. ...
    (comp.os.linux.misc)
  • Re: [kinda ot] writing the date into a file when saving it
    ... > i want to self-document source code files when i write them to disk. ... > find where:w is processed and cause it to look for a script to ... > i know about!command. ... To unsubscribe, ...
    (freebsd-questions)