How To Create A Daemon In Linux?
Recently we struck up with a problem. The problem is to run a script continuously in background and continuously check for a folder content changes. If any modifications are done in that folder, the script once again should start one more script. We thought of doing this by using crontab. But the problem with crontab is we have to wait at least one minute to run our script. One minute is too long for my requirement. We require a solution which runs continuously in background at every micro second, it should be similar to a normal Linux daemon such as httpd, ssh, ftp etc. I have searched in Google for creating daemons in Linux. But most of the people suggested to write a daemon in C language, which is alien to me(I have learnt C language some 9 years back but now totally forgot it 🙁 ). Here is one such link which will describe you how to create a daemon in Linux using C programming. http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html. I went through many documentations and other stuff but come to a conclusion to go with Shell script. Which will work same as daemon. Here is the code for the daemon which we accomplish using while loop while true; do if [ -f /testing/*.txt ] then echo “file created” mv /testing/*.txt /tst/ fi done This while loop continuously runs because we give...
Read More