Automatically running shell scripts using Upstart

Asellus

Honorable
Oct 25, 2013
21
0
10,510
Hey,

I got some shell scripts that I would like to run on start-up on my Linux server. I have been reading up on the Upstart feature, which seems to be the (best) way to do this. Is that correct?

And if so, is it correct that i need a .conf file for each located in the /etc/init/ folder, right?

And lately, am I correct in assuming that such a script could look like this:
C++:
# Dataserver Service Template

description   "Server"
author        "Me <my@email.com>"

start on runlevel [2345] 	# Start on the given runlevels
stop on runlevel [!2345] 	# Stop if NOT in one of the given runlevels

respawn			# Restart the job if ended without -o
respawn limit 5 10 	# Maximum of 5 respawn in a 10 second period

env SERVER_NAME = somename # Change to specifed server

# Run the actual server script
exec C:/SERVER_NAME/server.sh
 

stillblue

Honorable
Nov 30, 2012
1,163
0
11,660
Actually, I use cron. You can schedule when events happen, daily, hourly every 37 seconds even at boot.

A good explanation is here https://help.ubuntu.com/community/CronHowto

in a nutshell normal programs you type in a terminal on your server
crontab -e
add the command you want run and save

for a job that needs root you make the crontab in root
for example an Ubuntu server
sudo crontab -e
an example command to launch the openmeetings sh script when system boots

@reboot sh /var/www/openmeetings/red5.sh
 

Asellus

Honorable
Oct 25, 2013
21
0
10,510


Thank you for the response (and sorry for my late feedback). I will consider Cron, but I would still like to know if I got the part about how to use Upstart correct. Is there anyone who can help regarding that?