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

    Is it possible to schedule a command with pfSense?

    Scheduled Pinned Locked Moved General pfSense Questions
    14 Posts 5 Posters 14.3k 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.
    • M
      MuDvAyNe
      last edited by

      Just wondering if there was a way to schedule a command to kick off
      at a certain time using the webGUI. I would basically like to restart the
      firewall wall around 4:00am every morning. How would I be able to
      accomplish this?
      If it can't be done via the webGUI, can it be automated with an SSH client
      or even telnet?

      Thanks


      pfSense v 1.2-Release
      PII 350 256MB RAM
      HD Installed
      Cable Internet Connection
      LAN/WAN/DMZ
      Outbound Rules
      Inbound NAT

      1 Reply Last reply Reply Quote 0
      • S
        sullrich
        last edited by

        You can use ssh to edit /etc/crontab and schedule it there.

        1 Reply Last reply Reply Quote 0
        • H
          hoba
          last edited by

          Already discussed here: http://forum.pfsense.org/index.php/topic,1541.0.html

          If you just want to disconnect and reconnect your PPPoE at 4am add this line (guess you are fighting with the 24h disconnects and don't want them to happen during daytame and voipcalls for example):

          *	4	*	*	*	root	killall mpd && /usr/local/sbin/mpd -b -d /var/etc/ -p /var/run/mpd.pid pptp
          
          1 Reply Last reply Reply Quote 0
          • M
            MuDvAyNe
            last edited by

            Last night, I logged into my router with WinSCP and edited the /etc/crontab file putting in the line that you specified and saving the file. When I got up this morning, it didn't appear to work. I had the same IP address. I thought I would take a look at it remotely when I got to work, like a dumba$$, and added this line to my /etc/crontab file.

            55 10 * * * root killall mpd && /usr/local/sbin/mpd -b -d /var/etc/ -p /var/run/mpd.pid pptp

            I wanted to see if it would disconnect and then reconnect it at 10:55am and it looks like it disconnected, but still hasn't come back up. I have a program that emails me my new IP address at work
            and some other ways of getting into my system. It looks like the router is either crashed or just disconnected from the Internet. Did I make a boo boo somewhere? I also notice the last line in the command says "pptp"…should this have been "pppoe" if I just want to drop the DSL connection? If I just want to drop the PPPOE connection, and have it auto connect to get a new IP, what is the command?

            Also, if I wanted to just do a complete system reboot once a week, would this be the line to use:

            • 4 * * 7 root shutdown -r now

            pfSense v 1.2-Release
            PII 350 256MB RAM
            HD Installed
            Cable Internet Connection
            LAN/WAN/DMZ
            Outbound Rules
            Inbound NAT

            1 Reply Last reply Reply Quote 0
            • S
              sullrich
              last edited by

              You have to restart cron.

              killall cron ; cron

              1 Reply Last reply Reply Quote 0
              • H
                hoba
                last edited by

                mpd handles pppoe and pptp as well.

                1 Reply Last reply Reply Quote 0
                • M
                  MuDvAyNe
                  last edited by

                  Well, I have been screwing around with my Cron settings and here is what I came up with.

                  I was able to perform a successful reboot of pfSense by adding this line:

                  30	4	*	*	6	root	shutdown -r now
                  

                  So, I think this is pretty simple and I should be able to handle this without problems. It takes care of
                  an occasionally wanted/needed auto reboot.

                  I like hoba's idea of just dropping the DSL connection and bringing it back up, but with JUST the
                  command he provided below, I can only get it to DROP the connection. What tells it to reconnect?

                  *	4	*	*	*	root	killall mpd && /usr/local/sbin/mpd -b -d /var/etc/ -p /var/run/mpd.pid pptp
                  

                  I saw that you posted the killall cron ; cron but I don't know what to do with this or
                  how it would reconnect my DSL. I guess it restarts the CRON service but doing this doesn't get me back online. I tried running it before and after running the above command, but my DSL connection just stays down.

                  So…. ;D....I started screwing around looking for what would reconnect the DSL, and I think I am going
                  to get slapped for this, but it seems to bring the connection back up.

                  I ran this file two mins after hoba's command.

                  2	4	*	*	*	root	etc/rc.reload_interfaces
                  

                  This apparently reloads all of my connections (like a World War 2 carpet bombing) and gets me backonline. My question is, is there a BETTER way to just bring the PPPOE back up without have to reload ALL interfaces? Before you hurt me, I am a dreaded Windows user that is at least trying to understand this FreeBSD stuff. I feel like I was dropped off in the middle of Bejing with no tour guide. It is all Chinese to me.

                  9-30-06
                  I found out the hard way that if you update your SNAPSHOT to a newer version, it wipes out your custom CRONTAB settings. So I am now making a backup of this file.
                  Another side note, I read somewhere that in order for the CRONTAB file to execute properly, there needs to be a full BLANK line after the last command. If you look at the file BEFORE you edit it, you will see what I am talking about. I think this may have been what caused my commands to not work the first time.


                  pfSense v 1.2-Release
                  PII 350 256MB RAM
                  HD Installed
                  Cable Internet Connection
                  LAN/WAN/DMZ
                  Outbound Rules
                  Inbound NAT

                  1 Reply Last reply Reply Quote 0
                  • P
                    pixeldoc2000
                    last edited by

                    I have tested this, reconnects pppoe wan connection at 5 o'clock in the morning:

                    1. edit crontab
                    webGUI >> Diagnostics >> Edit File: /etc/crontab

                    *       5       *       *       *       root    killall mpd ; sleep 5 ; /usr/local/sbin/mpd -b -d /var/etc/ -p /var/run/mpd.pid pppoe
                    

                    (look at look at GUI >> Diagnostics >> Command Prompt: "ps ax | grep mpd")

                    2. restart cron
                    webGUI >> Diagnostics >> Command Prompt:

                    killall cron ; cron
                    

                    Just thought this comment would be usefull, maybe this safes time for some pfBuddies…

                    1 Reply Last reply Reply Quote 0
                    • H
                      hoba
                      last edited by

                      Daniel S. Haischt has kindly integrated this feature in the gui. Download the following Patchfile for Version 1.0.1: http://www.pfsense.com/~dsh/updates/pppoe-reset-embedded.tgz

                      You can feed it as firmwareupgrade through the webgui.

                      After that you can configure the ppoe reset at interfaces>wan, pppoe area "periodic reset".

                      Please give us some feedback so we can include this feature in one of the next releases.

                      1 Reply Last reply Reply Quote 0
                      • M
                        MuDvAyNe
                        last edited by

                        I have been running my pfSense with pixeldoc2000's crontab setting for about a week now and it is working flawlessly. Thank you very much for this.

                        I am downloading the "patch" and will try that using the GUI.

                        Just a question, is the "patch" just incorporating pixeldoc2000's crontab settings into the web interface? Or is this a totally different way of restarting the PPPOE?
                        I am assuming that I will have to remove pixeldoc2000's command from my crontab.


                        pfSense v 1.2-Release
                        PII 350 256MB RAM
                        HD Installed
                        Cable Internet Connection
                        LAN/WAN/DMZ
                        Outbound Rules
                        Inbound NAT

                        1 Reply Last reply Reply Quote 0
                        • M
                          MuDvAyNe
                          last edited by

                          The uploaded image file is not for this platform (pfSense).  :'(

                          This is what I get when I try to upload this patch through the firmware update.

                          I was thinking of just manually extracting the files and uploading them to my firewall via WinSCP
                          but I would like a second opinion before I blow things up. Has anyone else been able to succesfully
                          perform this patch?


                          pfSense v 1.2-Release
                          PII 350 256MB RAM
                          HD Installed
                          Cable Internet Connection
                          LAN/WAN/DMZ
                          Outbound Rules
                          Inbound NAT

                          1 Reply Last reply Reply Quote 0
                          • S
                            sullrich
                            last edited by

                            If you are on a full installation then rename the file pfSense-update.tgz and try again.

                            1 Reply Last reply Reply Quote 0
                            • D
                              DanielSHaischt
                              last edited by

                              @MuDvAyNe:

                              Just a question, is the "patch" just incorporating pixeldoc2000's crontab settings into the web interface? Or is this a totally different way of restarting the PPPOE?
                              I am assuming that I will have to remove pixeldoc2000's command from my crontab.

                              Yes, your assumption is correct. You need to remove each crontab entry that tries to restart the  mpd daemon before using the firmware upgrade. Anything else would lead to multiple mpd related entries in your crontab, which is something you don't want.

                              Cheers
                              Daniel S. Haischt

                              Mit freundlichen Gruessen / With kind regards
                              DAn.I.El S. Haischt

                              1 Reply Last reply Reply Quote 0
                              • M
                                MuDvAyNe
                                last edited by

                                Thanks for the tip with the archive rename and the Crontab question. Worked just fine after I did that.

                                I will post any problems (if any) after I run it for a bit. This is a very nice feature that I have been looking
                                for for a while and would love to see it incorporated into a future build.


                                pfSense v 1.2-Release
                                PII 350 256MB RAM
                                HD Installed
                                Cable Internet Connection
                                LAN/WAN/DMZ
                                Outbound Rules
                                Inbound NAT

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