Is it possible to schedule a command with pfSense?
-
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
-
You have to restart cron.
killall cron ; cron
-
mpd handles pppoe and pptp as well.
-
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. -
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…
-
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.
-
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. -
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? -
If you are on a full installation then rename the file pfSense-update.tgz and try again.
-
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 -
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.