I would like run my bash script (kvm_manage) in startup, and it doesnt work. Here is my upstart .conf script:
description "kvm start skript"
start on local-filesystem
stop on shutdown
respawn
script
exec /etc/kvm_manage start
end script
I want run it with argument "start". It is possible? What should I change?
thanks for help
Linux startup scripts are tools or programs that are run by the kernel each time your system restarts. Users can leverage various Linux startup commands to configure programs or run certain tasks once the system has booted. Luckily, there are several ways to auto-execute startup scripts in Linux.
You can configure startup commands in several ways. We will demonstrate the use of Linux CRON jobs and init tasks for running scripts at startup. We will also show you how to do this using Upstart. CRON is a simple but powerful job scheduler that can run certain tasks at system reboot. We can easily create a startup job using CRON.
In this article, we took a look at different ways of executing a script at startup in Linux. Each one of them has its pros and cons, but generally speaking, systemd and cron should be preferred when available. Meanwhile, rc.local and init.d can be used as fallbacks.
This is usually the case for most Linux distributions. And, if your script uses environment variables, you must include those at your crontab. One simple method of running jobs at reboot is to place them in the /etc.init.d directory. But first, make sure the script is executable.
Running a command via exec
with arguments is fine - see http://upstart.ubuntu.com/wiki/Stanzas#exec which gives such an example.
However, upstart will use /bin/sh
not bash
, so if your script needs bash you'd need something like
script
exec bash -c '/etc/kvm_manage start'
end script
Update: See also the suggestion in the comments from Guss to use the exec
stanza instead for simple cases:
exec bash -c '/etc/kvm_manage start'
Or if kvm_manage
is an executable with a she-bang (#!/bin/bash
), then simply:
exec /etc/kvm_manage start
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With