Cron does not function correctly with Ramdisk

  • I am running the regular installation of pfsense 2.1.5 but used the option: Use memory file system for /tmp and /var
    to prolong the life of my SSD.

    I installed the cron package and added the line (from gui):
    */60 * * * * /usr/local/bin/python /usr/shutdown/
    The script does execute faulty when started this way.

    Now, if I disable the ramdisk and edit the crontab from shell (as root) it works:
    crontab -e

    */60 * * * * /usr/local/bin/python /usr/shutdown/

    Upon enabling the ramdisk again, this crontab is unfortunately forgotten by the system. (Probably  it is stored on the /var or /tmp partition.) But if I disable the ramdisk from the gui, the entry is back and can be found entering: crontab -l.

    How can I make this entry persistent on the ramdisk? Any Ideas?

  • The cron entry going away is unrelated to the RAM disk. You can't manually edit crontab, it'll get overwritten at some point. Using the cron package is the correct way to add that. You're likely missing something related to path in your python code that makes it not work.

  • Yeah. But I can't find an option to enter SHELL, PATH and HOME in the package and it does not work without these settings. Maybe I am overlooking something obvious?

  • That isn't an option there. Just use full paths in your python, that's always best regardless when you're running from cron (or in general for that matter).

  • i am sorry, I thought I used the full paths in my config above. Please advice.
    Could the cron package use a different version of python than the one I installed by hand? I there some sort of logfile for what happens with cron? I don't know what the exact error is, otherwise.

  • within the actual .py I mean, what you're showing as the cron entry is fine, that part won't have any path issues.

Log in to reply