Ubuntu – crontab not running on VirtualBox unless I’m logged in

cronUbuntuvirtualbox

I am running Ubuntu Server 9.04 in VirtualBox on my work PC as a development environment. I have some scripts that I've put in my user's crontab that run throughout the day while I'm SSHed into the VM.

Last night, I closed PuTTy and all of my other running applications (except for VirtualBox and the VM) and went home. I came back this morning to discover that my cron jobs didn't run at all, yet when I SSHed into the VM, the next scheduled job ran. I set the schedule to 5min to test, disconnected again, and the jobs stopped running on schedule.

They seem to only run if I'm logged in to the machine. Obviously, I want them to run on schedule even if I'm not logged in to the VM, otherwise there's no point.

Is there something I've failed to configure correctly?

New Information:

There are now 3 entries in /var/log/cron.log saying the following "Mount of private directory return code [256]"… the entries correspond to when the cron job is supposed to run.

I thought they are supposed to run as my userid? Why would my own userid be unable to run a script in my home directory?

Best Answer

It would appear that you are trying to run a cron job as your user, and that you have some form of encrypted home directory set up.

Your home directory (or some subset thereof) is unlocked and mounted when you log in, but when you are logged out, your home directory is unavailable, thus the error in your logs.

You should remove the encryption, run the cron job as another user, or you could try to run the job as your user but specifying a different environment (HOME, most notably).

Related Topic