DEMO
So, how could we turn one of our into a daemon? One first attempt could be using&
. The trailing ampersand is a Bash built-in which instructs the shell to run the command in the background inside a subshell. Once the command is executed, the shell does not wait for it to finish but returns a code 0
, which means successful, and proceeds further in any other commands that are to be executed:
zarrelli:~$ ls -lah & ps -jf [1] 13704 total 48K drwxr-xr-x 4 zarrelli zarrelli 4.0K Apr 12 14:12 . drwxr-xr-x 4 zarrelli zarrelli 4.0K Apr 12 19:37 .. -rw-r--r-- 1 zarrelli zarrelli 11 Apr 10 09:20 controller -rwxr--r-- 1 zarrelli zarrelli 121 Apr 11 18:30 coproc.sh -rwxr--r-- 1 zarrelli zarrelli 961 Apr 11 12:19 environment.sh -rwxr--r-- 1 zarrelli zarrelli 382 Apr 11 10:08 looping.sh -rw-r--r-- 1 zarrelli zarrelli 0 Apr 10 09:20 myfile.txt -rw-r--r-- 1 zarrelli zarrelli 122 Apr 10 09:20 myfile.txt.tgz -rw-r--r-- 1 zarrelli zarrelli 367 Apr 12 14:12 my_index.html prw-r--r-- 1 zarrelli zarrelli...