Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Cron does not function correctly with Ramdisk

    Scheduled Pinned Locked Moved pfSense Packages
    6 Posts 2 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      beatstick
      last edited by

      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/conditionalshutdown.py
      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

      SHELL=/bin/sh
      PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
      HOME=/
      */60 * * * * /usr/local/bin/python /usr/shutdown/conditionalshutdown.py

      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?

      1 Reply Last reply Reply Quote 0
      • C
        cmb
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • B
          beatstick
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • C
            cmb
            last edited by

            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).

            1 Reply Last reply Reply Quote 0
            • B
              beatstick
              last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • C
                cmb
                last edited by

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.