November 24th, 2001, 10:44 AM
high priority scripts at startup
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,
November 24th, 2001, 03:40 PM
1) Which BSD? All 3 uses different rc mechanism.
2) What does your script do?
3) What are the dependencies your script needs?
November 24th, 2001, 04:16 PM
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)
November 24th, 2001, 04:27 PM
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.