Re: Best way to run command on system start
- In reply to: Polarian : "Best way to run command on system start"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 04 May 2024 17:26:21 UTC
On Sat, 4 May 2024 15:08:14 +0100, Polarian wrote:
> [...]
> I have read the forums and seen suggestions of using a rc service to
> set the backlight on boot, however there must be a better way to do
> this.
Yes, a rc.d-style script is the recommended solution, but if
everything you need to execute is just one simple command at
system boot time, create /etc/rc.local and place it there,
with full path.
A typical /etc/rc.local would start with:
#!/bin/sh
if [ -z "${source_rc_confs_defined}" ]; then
if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
source_rc_confs
elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
elif [ -r /etc/rc.conf.local ]; then
. /etc/rc.conf.local
fi
fi
This allows you to add custom options to /etc/rc.conf or
/etc/rc.conf.local, and your own scripts can benefit from
the defaults in /etc/defaults/rc.conf, if that's needed.
It can then contain your commands, like
echo -n " backlight"
/usr/bin/backlight 50
It will print a "description" of the current task and then
execute it. If you have more than one of such tasks, the
console output will look like this:
Starting local daemons: activity startsound parallel.
But as it has been mentioned, /usr/local/etc/rc.d (or maybe
even /opt/rc.d) is the proper thing to do if you need to run
something more complicated.
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...