Hi Guys, I have a script to help me sync 2 file servers but my problem is its not working whenever I run it on startup like adding it on /etc/rc.local although I can see it running on process list. But if I run in on the shell it works. Please see my script below: #!/bin/bash inotifywait -mr -e close_write -e create -e delete -e move /folder | while read DELETE CREATE MOVE ; do unison ; done Thanks,
Try to use the full path to inotifywait and if this does not help, try to send the process to the background.
Cronjobs and probably also rc scripts dont use the search pth, so paths to commands have to be defined as absolute path. Did you try to send this job to the background with: &> /dev/null at the end of the line in /etc/rc.local where you call your script?
Still didn't work. Looks like someone has the same problem too but no one has the answer yet. :-( http://serverfault.com/questions/655410/running-inotifywait-on-startup-of-machine
Does it work as cronjob? Then you can e.g. start the script as 5 minute cronjob, extend the code in the script to check with ps if inotify is running, if it is not running, then start it, otherwise quit the script.
Yes thats what I ended up doing. Since I noticed it was running perfectly when using at, I made a script on cron to run it if its not. Still a mystery though. Thanks alot Till!
Which of init systems do you have on your server/distribution? You need to have a correct header in Your script when you want to use it on startup. Look http://www.thegeekstuff.com/2012/03/lsbinit-script/