Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Run Jobs after system start and before shutdown?

Status
Not open for further replies.

Sina

Technical User
Jan 2, 2001
309
0
0
CA
hello everyone;

I just wanted to know where to put my start and stop scripts to run the start jobs at the boot time and my stop jobs at shutdown.

For example I would like to start my mysql db at start and shutit down when the server is going down.

I like to run this jobs to start mysql when the system is coming up.
/bin/sh -c 'cd /usr/local/mysql; ./bin/safe_mysqld'

And run the
su - oracle -c "/oracle/product/8.1.7/bin/lsnrctl stop"
when the server is going down.
where should I place these lines?


thank you all


 
If you installed mysql from ports take a look at /usr/local/etc/rc.d/mysql.sh-dist

If you rename it to remove the '-dist' it will start up automatically. rc.d is the place to put your startup scripts but I never run shutdown scripts because I rarely shutdown my servers but look at /etc/rc.shutdown for that.

Hope that helps,

FredUG
 
Hi folks,

In FreeBSD, all the script files located in /usr/local/etc/rc.d/ directory will be run with start argument in system startup and with stop argument on system shutdown. So, all you need to do is to create a script /usr/local/etc/rc.d/service.sh and handle start and stop arguments properly.

For example, to start UPS monitoring tool, create script like this:

--------------
#!/bin/sh
case "${1}" in
start)
upsd
upsmon apcsmart
upslog hostname ups.log 15
echo -n " ups"
;;
stop)
/usr/bin/killall upslog upsmon upsd apcsmart
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
;;
esac

exit 0

---------------

Regards,
Murad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top