I currently filter out data from a MQTT live stream. I then dump this datum into a csv file named mqtt.csv and the dumping process is done by executor_start_up_job.txt which is written in BASH.
I want to make the dumping of the filter daemon, i.e. in the background, and also want to make it in so that every time the system is rebooted it is done automatically. So I've concluded to write an init.d script, and contents of my code is:
#!/bin/bash
. /etc/init.d/MySQL_table_update_daemon.txt
start() {
initlog -c "echo -n Starting the dump to mqtt.csv "
/home/ed/start_up_job/executor_start_up_job.txt &
}
# Restart the Dump
stop() {
initlog -c "echo -n Stopping the dump to mqtt.csv "
killproc FOO
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "last print line: `cat mqtt.csv | tail -1"
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
Q: It's my first time writing an init.d and I have written my code based on this example, would the above code work?
Aucun commentaire:
Enregistrer un commentaire