The location of the upstart script /etc/init.d/heartbeat.conf
is correct, but there are few other issues with the script:
Recommended way to start the script is:
start on filesystem and net-device-up IFACE!=lo
This will ignore the
lo
(loopback) interface, and will also ensure that filesystems are mounted before the script runs (since you are writing to a file)You have given path as
~/heartbeat/ping.log
. But the script will run asroot
user, not your user! So checking in your home folder won't work. Also generally, upstart scripts don't honor~
as you would expect. So always use a full pathIf a folder called
heartbeat
doesn't exist, then the ping command itself would throw an error, saying~/heartbeat: no such file or directory
. The directory must exist in order for the redirection to succeed
Here is the updated script:
start on filesystem and net-device-up IFACE!=lo
stop on runlevel [016]
script
ping -i 30 192.168.1.1 >> /full/path/to/ping.log 2>&1
end script
Optional items:
Do you really need a
| cat
in the original ping command?Check
/var/log/upstart/heartbeat.log
for the actual upstart logs. If thescript
section itself did not succeed, then the error messages would be present in this log file.
Edit: Typo, start better, redirect error also to log file