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 set -x requested_command=$1 start() { /home/ed/start_up_job/executor_start_up_job.txt & } # Restart the Dump stop() { killproc executor_start_up_job.txt echo } ### main logic ### case $requested_command in start) start ;; stop) stop ;; status) last_line=`cat mqtt.csv | tail -1` echo "last print line: $last_line" ;; restart) stop start ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0
Once I have inserted set -x
I get the following output:
+ ./MySQL_table_update_daemon.sh start
+ requested_command=start
+ start
+ exit 0
Q: It's my first time writing an init.d
and I have written my code based on this example it doesn't work, as I get the error "segmentation fault
"
MySQL_table_update_daemon.txt
is a very odd name for something executable that would be found in/etc/init.d
, as has been pointed out already.)#!/bin/bash
to make this (MySQL_table_update_daemon.txt
) an executable. I've commented out the./etc....daemon.txt
and currently I am trying to make the code run from the terminal but it doesn't work. The output is just nothing, its as if I've just pushed enter from the terminal; my input to the terminal is./MySQL_table_update_daemon.txt start
bash -x
to see what it's doing. It might be working find except that/home/ed/start_up_job/executor_start_up_job.txt
is doing nothing. By the way, that's also a very odd name for an executable. What's with the.txt
suffix everywhere?