Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Debian 6 64bit.

What I'm trying to do is run Unison on startup to constantly monitor files on the LAMP server I have running on my VM and sync that with the VM Shared folder.

while true
do
    unison -batch -owner -group /folder1/ /folder2/
    sleep 10
done

Now, I can get this script to run at startup... but the problem is that it hangs. Even if I use nohup, it hangs at the nohup dialog.

Also, if there is a way I can use nohup I'd really rather it not log anything at all. However, I can't find this option in either nohup or unison documentation. I may be overlooking it, but I can't find it.

I'm sure there is a way to link Apache to another folder and just use that... but I still want to know how to do this because I could use it in different contexts as well.

Thank you

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Why not to point Apache to your shared folder on VM in the first place? This is as simple as to add/change one file for your virtualhost (I believe you've done this anyway). This will let you not to wait 5-10 seconds while your server document root is being updated.

However what you actually ask is a periodically running some command, so in the end you just need a cron job. This answer may be helpful for you.

So you just add to your crontab file:

* * * * * unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1
* * * * * sleep 10; unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1
* * * * * sleep 20; unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1
* * * * * sleep 30; unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1
* * * * * sleep 40; unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1
* * * * * sleep 50; unison -batch -owner -group /folder1/ /folder2/ >/dev/null 2>&1

The >/dev/null 2>&1 means to redirect stdout and stderr output i.e. remove all logging.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.