#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    8
    Rep Power
    0

    high priority scripts at startup


    Main question:
    How do I make a program run as root at startup?

    I've got a perl script, that runs in the background. I usually start it as root, because the script will run another program with the highest priority (nice --20), so I'll need to run as root. Now I want this script to go into the background at startup. I did this, but the nice --20 won't work, because the script doesn't run as root...


    Thanks in advance,

    d0g1e@cyberspace.org
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    1) Which BSD? All 3 uses different rc mechanism.
    2) What does your script do?
    3) What are the dependencies your script needs?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    8
    Rep Power
    0
    I'm using FreeBSD

    The script is a perl script. It reads a queue every two seconds and, if a new mp3 has been added, it will play the mp3 using mpg123.

    the command is something like:

    system("nice --20 mpg123 $mp3Filename &");

    I want it to run at top priority, because the server is a pentium 60 with 16 megs of ram, and it doubles as a small webserver. I wan't to prevent hick-ups in the mp3 playback, when people flood the webserver with requests. (I already reconfigured apache, but I'm not going to allow less clients, I've already reached the minimum for my environment)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    Put your script to /usr/local/etc/rc.d/ directory. At the minimum, your script should expect two args: start and stop, so it can start/stop properly.

    Check out http://www.perl.com/CPAN-local/modul...module/Getopt/

    How to code your script is beyond the scope in BSDs forum.

    If you are talking about startup priority, FreeBSD has a poor mechanism for local scripts. It will look for your script name in the order of 0-9, then A-Z, then a-z.
    Last edited by freebsd; November 24th, 2001 at 04:30 PM.

IMN logo majestic logo threadwatch logo seochat tools logo