A Daemon is just program that runs as a background process, rather than being under the direct control of an interactive user...
[The below bash code is for Debian systems - Ubuntu, Linux Mint distros and so on]
The simple way:
The simple way would be to edit your /etc/rc.local file and then just have your script run from there (i.e. everytime you boot up the system):
sudo nano /etc/rc.local
Add the following and save:
#For a BASH script
/bin/sh TheNameOfYourScript.sh > /dev/null &
The better way to do this would be to create a Daemon via Upstart:
sudo nano /etc/init/TheNameOfYourDaemon.conf
add the following:
description "My Daemon Job"
author "Your Name"
start on runlevel [2345]
pre-start script
echo "[`date`] My Daemon Starting" >> /var/log/TheNameOfYourDaemonJobLog.log
end script
exec /bin/sh TheNameOfYourScript.sh > /dev/null &
Save this.
Confirm that it looks ok:
init-checkconf /etc/init/TheNameOfYourDaemon.conf
Now reboot the machine:
sudo reboot
Now when you boot up your system, you can see the log file stating that your Daemon is running:
cat /var/log/TheNameOfYourDaemonJobLog.log
• Now you may start/stop/restart/get the status of your Daemon via:
restart: this will stop, then start a service
sudo service TheNameOfYourDaemonrestart restart
start: this will start a service, if it's not running
sudo service TheNameOfYourDaemonstart start
stop: this will stop a service, if it's running
sudo service TheNameOfYourDaemonstop stop
status: this will display the status of a service
sudo service TheNameOfYourDaemonstatus status