Why crontab not working?

Couple of days ago I wrote a post Stop ubuntu from Hibernating, fixing crontab but the problem wasn’t solved. Cron was running (I checked the log) but my python script wasn’t being executed.

What I found out was when putty session to my server is closed the home directory is unmounted, I believe. My home directory contained all my python scripts.

The cron was trying to run scripts that didn’t exist, so nothing was happening. So what I did was move all my python scripts to the directory /var/ and changed the crontab to execute scripts that are located in there and I hadn’t had any issues since.

Resources:
http://ubuntuforums.org/showthread.php?t=1530652#post_9598668

Global Modules for Python

When importing inside a python script it first looks to see if the file is inside the current directory but if not it looks to see its in the python global folder(source) which in:

/usr/lib/python2.7/
or
/usr/lib/python3.2/

I like to create a symbolic links so I can still have my files inside a directory of my choosing and it being global.

$ ln -s /var/fsq/python/fsq_modules/ /usr/lib/python3.2/fsq_modules

PS.
there must be a __init__.py in the directory for it to work
http://stackoverflow.com/questions/338768/python-importerror-no-module-named

Stop ubuntu from Hibernating, fixing crontab

Recently I was having issues with cron not executing between the times of 10pm to 9am and when I didn’t access the server for an extended period of time. The issue I found was that my server was hibernating/sleeping at those times and cron doesn’t execute if that happens. My ubuntu server doesn’t have a GUI so everything needs to be configured in the command line. So here is what I did.

edit the grub file:

$ sudo nano /etc/default/grub

Add the kernel options “acpi=off apm=off” to the GRUB_CMDLINE_LINUX_DEFAULT:

GRUB_CMDLINE_LINUX_DEFAULT="acpi=off apm=off"

Then run:

$ sudo update-grub

Reboot your computer.

Resources:
http://unix.stackexchange.com/questions/25133/ubuntu-server-continuously-goes-to-sleep/25151#25151
http://askubuntu.com/questions/47311/how-do-i-disable-my-system-from-going-to-sleep

tag:
turn off ubuntu server hibernation