Re: schedule a script at system startup

2005-12-07 Thread Drew Tomlinson

On 12/4/2005 6:14 AM Werther Pirani wrote:


Ian Lord wrote:


I guess there might be a way to put a script in /etc/rd.d/ but I
don't know how to run it under a specifid uid



Create a script (name is not important as long as it ends in .sh)



Although customary, it does not have to end in .sh AFIK

Cheers,

Drew.


and put it in /usr/local/etc/rc.d. Also, make sure the script is
executable and contains lines like:

#!/bin/sh

echo -n  some informative message here

su -l username -c '( command arg1 ... argn )'

Run the script (as root) manually with /usr/local/etc/rc.d/sctript.sh to
verify everything is okay and in case you need/want to add redirection
(still inside parenthesis).



Hope this helps,

Werther




--
Visit The Alchemist's Warehouse
Magic Tricks, DVDs, Videos, Books,  More!

http://www.alchemistswarehouse.com

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-04 Thread Scott Mitchell
On Sat, Dec 03, 2005 at 08:18:12PM -0500, Ian Lord wrote:
 Hi,
 
 I would like to run a shell script at system startup which needs to 
 run under a specific uid...
 
 I don't see anything for this in man cron...

Try 'man 5 crontab' - there's an @reboot string that can be used instead of
the normal time specification in a crontab file to have the command run
once at startup (of the cron daemon, presumably).

 is there a way to do it with cron ? or otherwise is there another way ?
 
 I guess there might be a way to put a script in /etc/rd.d/ but I 
 don't know how to run it under a specifid uid

Your rc.d script could just use 'su' to switch to the desired user and
execute another script as that user:

su - someuser -c /path/to/some/script

su passes everything after the username as arguments to the shell running
as someuser.

I guess the advantage of running your script out of /etc/rc.d is that you
can control when it gets run relative to all the other startup scripts -
'man rcorder' for details on this.

Cheers,

Scott

-- 
===
Scott Mitchell   | PGP Key ID | Eagles may soar, but weasels
Cambridge, England   | 0x54B171B9 |  don't get sucked into jet engines
scott at fishballoon.org | 0xAA775B8B |  -- Anon
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-04 Thread Werther Pirani

Ian Lord wrote:


I guess there might be a way to put a script in /etc/rd.d/ but I
don't know how to run it under a specifid uid


Create a script (name is not important as long as it ends in .sh)
and put it in /usr/local/etc/rc.d. Also, make sure the script is
executable and contains lines like:

#!/bin/sh

echo -n  some informative message here

su -l username -c '( command arg1 ... argn )'

Run the script (as root) manually with /usr/local/etc/rc.d/sctript.sh to
verify everything is okay and in case you need/want to add redirection
(still inside parenthesis).



Hope this helps,

Werther
--
I went mad for a while -- did me no end of good.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-04 Thread Svein Halvor Halvorsen

* Ian Lord [2005-12-03 20:18 -0500]
  I would like to run a shell script at system startup which needs to run under
  a specific uid...
  
  I don't see anything for this in man cron...

See crontab(5)

You can use the @reboot magic to make cron run a script once, at startup.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-04 Thread 赵铭
sometime ,you can use the commant : su - usename -c commant

man su

you will find it..good luck


On 12/4/05, Svein Halvor Halvorsen 
[EMAIL PROTECTED] wrote:


 * Ian Lord [2005-12-03 20:18 -0500]
   I would like to run a shell script at system startup which needs to run
 under
   a specific uid...
 
   I don't see anything for this in man cron...

 See crontab(5)

 You can use the @reboot magic to make cron run a script once, at startup.
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]




--
==
NAME :webnamechina
N U M :9809338
[EMAIL PROTECTED]
==
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-04 Thread Daniel Rudy
At about the time of 12/3/2005 5:18 PM, Ian Lord stated the following:

 Hi,
 
 I would like to run a shell script at system startup which needs to 
 run under a specific uid...
 
 I don't see anything for this in man cron...
 
 is there a way to do it with cron ? or otherwise is there another way ?
 
 I guess there might be a way to put a script in /etc/rd.d/ but I 
 don't know how to run it under a specifid uid
 
 Any help would be appreciated
 
 Thanks
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
 

@reboot username command

The @reboot is a BSD extension.

-- 
Daniel Rudy
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: schedule a script at system startup

2005-12-03 Thread Colin Andrew Percival
On Sat, Dec 03, 2005 at 08:18:12PM -0500, Ian Lord wrote:
 I would like to run a shell script at system startup which needs to 
 run under a specific uid...
 
 I don't see anything for this in man cron...
 
 is there a way to do it with cron ? or otherwise is there another way ?

Create a crontab file for the user, and use the magic value @reboot for
the date/time.

Colin Percival

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]