I have a virtual server running Ubuntu 14.04 LTS x64 and I want to create a persistent process that restarts with the system and when it crashes.
To do that, I've added the following lines to the "inittab" in the etc-directory:
test:5:respawn:echo "HELLO TEST" > /test.log sometestname:234:/var/path/to/process/myprocess
After running "init q" or "telinit q", nothing happens. The test.log file isn't created, the process isn't started (It's not listed when using pstree) and there's nothing in the syslog either. Restarting the server also doesn't help.
I've also tried to use systemd to create a new service, by creating a new "myprocess.service" in "/etc/systemd/system/" with these commands:
[Unit] Description=Process Name [Service] ExecStart=/var/path/to/process/myprocess Restart=restart-always [Install] WantedBy=multi-user.target
Again, after a server restart the process isn't there.
Are there any other ways to create a persistent process in Ubuntu?
Also, the process acts as a server, but can also accept user inputs. Since it'll run as a background process most of the time, is it possible to "attach" it to the main console at whim to run some commands, and detach it later on? I'm using putty for remote access to the server.