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

    Run custom shell script (not at boot time)

    Scheduled Pinned Locked Moved General pfSense Questions
    5 Posts 3 Posters 7.8k 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.
    • C
      cnd.fflv
      last edited by

      Hi guys.

      I was trying to search the answer but only found how to run script at the boot.

      Here is my question.

      I want some maintenance run at night (2am), when not much is going on on my LAN.

      I wrote the script, made it executable, add new cron job using crontab -e…

      But nothing went through. I tried to run script manually from CLI, and it didn't go.

      How can I do this?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • N
        NOYB
        last edited by

        Not really much info provided to go on so I’ll attempt being clairvoyant.

        Try this

        login as root
        cd to script directory
        chmod 777 script_file
        ./script_file

        If that does not work then something is probably wrong with the script.  Make a simple script to echo something out to the console and see if that will run.

        1 Reply Last reply Reply Quote 0
        • C
          cnd.fflv
          last edited by

          nope…. :(

          doesn't work. See attached screen shot.

          EDIT:

          works. It was my mistake. I put !/bin/bash instead of /bin/sh...

          Thanks for reply.

          All the best.

          ![Screen Shot 2014-02-24 at 3.24.47 PM.png](/public/imported_attachments/1/Screen Shot 2014-02-24 at 3.24.47 PM.png)
          ![Screen Shot 2014-02-24 at 3.24.47 PM.png_thumb](/public/imported_attachments/1/Screen Shot 2014-02-24 at 3.24.47 PM.png_thumb)

          1 Reply Last reply Reply Quote 0
          • P
            phil.davis
            last edited by

            Your edits to crontab will get lost when you reboot - pfSense rebuilds all that from its config at boot time. Install the cron package and use that to add your cron job. It will survive reboot.

            As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
            If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

            1 Reply Last reply Reply Quote 0
            • C
              cnd.fflv
              last edited by

              Thanks!

              I did as you advised.

              All the best.

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