Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was trying to use @reboot /my/script in cron to run a script on a 10.04.4 VM running in VMware Fusion top print ifconfig to a file on a shared directory, which is /mnt/hgfs/somedir.

It didn't work because hgfs is not mounted yet as a remote directory when the system starts. Is it possible to do something like @reboot +10s to run the cron job 10 sec after the system starts, when I can realistically expect to have that remote directory mounted on the system?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

You could simply add

sleep 10

to the beginning of your script. This way, your script will "sleep" (wait) 10 seconds before continuing.

share|improve this answer
    
brilliant, thanks. why didn't i think of that? –  amphibient May 8 at 22:38
add comment

For a more robust option, your cron job could be

 @reboot until [ -d /mnt/hgfs/somedir ]; do sleep 1; done; /my/script

That will wait until the directory actually exists, so you don't need to guess how long it will take or worry that it might take longer.

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.