>> "Barry Byrne" writes:
B> I think the simplest thing would be to write a little wrapper script
B> that calls your other script.
B> 
B> #!/bin/sh
B> echo "Stating Daemon Now"
B> /path/to/mainscript &

   You might be better off using daemon to make sure you're detached from
   the controlling terminal.  Other advantages are changing the working
   directory to / in case you need to unmount the filesystem from which
   the original program was run, and properly handling stdin/stdout/stderr.

>> On Sat, 06 Jun 2009 07:10:47 -0500, 
>> Martin McCormick <mar...@dc.cis.okstate.edu> said:

M> [...] the output can be redirected to /dev/null or anywhere
M> else when you call the script.  To kill it, do
M>   ps ax | grep SCRIPTNAME | grep -v grep

   If you're looking for an easy way to kill "mainscript", have it store
   its process-id somewhere:
      echo $$ > /var/run/`basename $0`.pid

M> As with all scripts that can start background processes, be careful with
M> loops and such...

   If you're working on each file in a directory, it helps to add
   something like this to the inner loop:
       test -f "stop" && echo stopped at user request && exit 1

   This way, you can just "touch stop" if something goes to hell instead
   of having to grub around in the process table.

-- 
Karl Vogel                      I don't speak for the USAF or my company
Therapy is expensive.  Popping bubble wrap is cheap.  You choose.
                                                           --bumper sticker
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to