Answering this question because it'd bad form to just edit your question to put the answer inline (really, just answer your own question, it's okay if done in good faith).
I had a similar problem - jobs started via cron appearing to work the first few times, but then failing. The symptoms all traced back to an inability to access the user's home directory and files within it. The same script and setup had worked just fine on a previous Ubuntu box.
The answer is that yes, if you chose to encrypt your $HOME directory during Ubuntu install, you'll find that cron jobs will not be able to access files under it, unless you happen to have manually logged into the machine to cause the file system to be decrypted and kept mounted. I said yes to that option because it sounded like a good idea, but I'm not firmly wedded to it.
The solution I'm going with is to not encrypt my home directory; which means I have to remove encryption from it. It looks like that's a careful process of shifting all the relevant contents out of the folder, unmounting it, and shifting them all back in - not pleasant.
The basic process I followed for this is below. NB: Be very careful and read through all the steps before following them, especially the final ones as I suspect that once you uninstall ecryptfs it will be very tricky to get your old encrypted home folder back. If you're not sure of what you're doing, don't try this as the risk of data loss is very real. I only plowed on ahead because I knew I had backups and could reinstall easily.
- Add a new user
fixer
using adduser
(because you need to be logged in as somebody other than yourself to shift your home directory around), and give them sudo rights
- Using sudo, Create a new folder
sudo mkdir /home/chrisc.unencrypted
to transfer the contents of your home directory to
- Copy the contents of my home directory to the new unencrypted folder using
rsync -aP /home/chrisc /home/chrisc.unencrypted
. Make sure that all the hidden files have moved too (e.g. .bash_profile, etc.)
- Remove the /home/chrisc.unencrypted/.ecryptfs folder
- Log out (and possibly reboot, as you need the encrypted /home/chrisc folders to be unmounted)
- Log in again as
fixer
- Use
sudo su
to run as root
- Check that the contents of
/home/chrisc.unencrypted
match what they should be. This is quite important, because the next few steps will remove your ability to see the original home folder
- Rename the old (encrypted) home using
mv /home/chrisc /home/chrisc.old
. You may find you need to reboot first to ensure that nothing is using that folder (otherwise you'll get a device in use message preventing the rename).
- Rename the unencrypted home folder to be the user's default folder
mv /home/chrisc.unencrypted /home/chrisc
- Uninstall the ecryptfs tools using
apt-get remove ecryptfs-utils libecryptfs0
. If I didn't do this, then logging in as chrisc, I saw an empty home directory (as if it was still mounting the encrypted home directory and hiding my actual unencrypted home directory). I had to reboot to get it to be unmounted and the real unencrypted /home/chrisc to be visible.
- Log in again as your original user and check
It may be possible to remove the configuration folder for ecryptfs, or that there's a per-user configuration somewhere that says "when you log in as chrisc, mount the ecryptfs volume available at /home/chrisc/.Private" If you could sever that link, then you probably wouldn't need to uninstall ecryptfs.
If your new home folder doesn't look like it contains the right things, you should be able to restore the encrypted home folder by reversing the moves - making chrisc.old
be chrisc
again, and the unencrypted home folder chrisc.unencrypted
. But that will only work up until the point you uninstall ecryptfs.
/home/user
using an automounter or is it encrypted? – garethTheRed Nov 19 '14 at 20:56ls -la
on /home/user and /home/user/cron_dir – SailorCire Nov 19 '14 at 22:02