Re: Run script as often as possible

2004-09-29 Thread Jacob Larsen
mysc:2345:respawn:/path/to/myscript
What does the 'mysc' do?
id:runlevels:action:process
"id is a unique sequence of 1-4 characters which identifies an entry in 
inittab"

from `man inittab`
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Run script as often as possible

2004-09-29 Thread Tom Allison

Dave Carrigan wrote:
On Tue, Sep 28, 2004 at 11:23:15AM +0200, Jacob Larsen wrote:
I have a script that I'd like to run as often as possible.

mysc:2345:respawn:/path/to/myscript
What does the 'mysc' do?
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Run script as often as possible

2004-09-28 Thread Kevin Mark
On Tue, Sep 28, 2004 at 11:23:15AM +0200, Jacob Larsen wrote:
> I have a script that I'd like to run as often as possible.
what does that mean? as many instances as possible until the cpu load in
maxed out?
> The script may only run in 1 instance.
And that would be ...

> My idea is to have a cron script to start it once every hour. 
is that: 
a specific time each hour?
a random time spaced one hour apart?

> The script 
> should write a run file, and if the run file exists, exit.
> Is this the best way?
the issues this probably addresses is concurrency. the way to address
this issue depends what you are trying to avoid:
two instances of the same program running at the same time overrighting
a file?
or something else?
> 
> Thanks,
> Jacob
=Kev
-- 

(__)
(oo)
  /--\/
 / |||
*  /\---/\
   ~~   ~~
"Have you mooed today?"...


signature.asc
Description: Digital signature


Re: Run script as often as possible

2004-09-28 Thread Jacob Larsen
mysc:2345:respawn:su - someuser -c /path/to/myscript
Thanks!
And I guess if I want to write output to a file I do this:
mysc:2345:respawn:su - someuser -c /path/to/myscript >> 
/var/log/myscript.log

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Run script as often as possible

2004-09-28 Thread Dave Carrigan
On Tue, Sep 28, 2004 at 04:49:49PM +, Adam Funk wrote:

> That runs the script as root, right?  If you wanted to run it with as
> another user, would you just stick a bit of sudo in that inittab
> entry?

Sure:

mysc:2345:respawn:su - someuser -c /path/to/myscript

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Hunters & Collectors - Everything's On Fire (Human 
Frailty)


signature.asc
Description: Digital signature


Re: Run script as often as possible

2004-09-28 Thread Adam Funk
On Tuesday 28 September 2004 16:30, Dave Carrigan wrote:

> On Tue, Sep 28, 2004 at 11:23:15AM +0200, Jacob Larsen wrote:
>> I have a script that I'd like to run as often as possible.
>> The script may only run in 1 instance.
>> My idea is to have a cron script to start it once every hour. The
>> script should write a run file, and if the run file exists, exit.
>> Is this the best way?
> 
> Run it from init by putting an entry into your inittab. As soon as it
> exits, init will respawn it. The upside is that there is no need to do
> locking or process synchronization. The following inittab entry would
> work.
> 
> mysc:2345:respawn:/path/to/myscript

That runs the script as root, right?  If you wanted to run it with as
another user, would you just stick a bit of sudo in that inittab entry?


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Run script as often as possible

2004-09-28 Thread Dave Carrigan
On Tue, Sep 28, 2004 at 11:23:15AM +0200, Jacob Larsen wrote:
> I have a script that I'd like to run as often as possible.
> The script may only run in 1 instance.
> My idea is to have a cron script to start it once every hour. The script 
> should write a run file, and if the run file exists, exit.
> Is this the best way?

Run it from init by putting an entry into your inittab. As soon as it
exits, init will respawn it. The upside is that there is no need to do
locking or process synchronization. The following inittab entry would
work.

mysc:2345:respawn:/path/to/myscript

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Creedence Clearwater Revival - Travellin' Band 
(Chronicle)


signature.asc
Description: Digital signature


Re: Run script as often as possible

2004-09-28 Thread Jacob Larsen
I have a script that I'd like to run as often as possible.
The script may only run in 1 instance.
My idea is to have a cron script to start it once every hour. The script 
should write a run file, and if the run file exists, exit.
Is this the best way?
yeah.  Accpeted method is to write a lock file to /var/lock and exit if
it exists
If the server boots, will /var/lock be emptied, or should I manually 
clean that area?

Thanks,
Jacob
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Run script as often as possible

2004-09-28 Thread Blake Swadling
On Tue, 2004-09-28 at 19:23, Jacob Larsen wrote:
> I have a script that I'd like to run as often as possible.
> The script may only run in 1 instance.
> My idea is to have a cron script to start it once every hour. The script 
> should write a run file, and if the run file exists, exit.
> Is this the best way?

yeah.  Accpeted method is to write a lock file to /var/lock and exit if
it exists

Cheers

Blake Swadling
Senior Software Engineer
Newton Pty Ltd

Telephone:
+61 2 6247 3544
Fax:
+61 2 6247 3533
Mobile:
+61 407 026277
Web:
http://www.newton.com.au




signature.asc
Description: This is a digitally signed message part