[Solved] pfSense Cron reboot with email-telegram notification
-
Hello!
First time writing here so be kind :)I have configured notifications from email-telegram and when i press reboot manually from webconfig and when it boots i get the message from both.
i am looking for once a week reboot in the pfsense with crone
I know that shutdonw -r now works with the time i want but i dont get the message but only when it boots up.
i know its kinda stupid but i would realy like getting full info of whats happening
i made a php(part copy from original one from menu)
If any info you want i am willing to assist,
thnx!
-
@armor-64 You would need to set up a cron job 10 - 15 secs before your cron shutdown task runs.
Queston really should be why do I need to reboot your router once a week?
-
You would need to call the appropriate php script to trigger the notifications as you show.
Have you tried running that?
-
This is the command on cron,probably its wrong if i need a scrip,how or what do i need to do to make it so? if there is a guide tha would help
Sorry new to this stuff no rly idea how pf work
-
@armor-64 cron job 10-15sec with a message command that i want? if yes how?
Restarting once a week its not a bad idea its home project so i want explore stuff etc
-
When you run something in cron you need to specify the full path and for a php script that mean the full path to php and to the script so it might be:
/usr/local/bin/php /root/my_reboot_script.php
Or use the full path to the binary in the script. So for example this script works. I simply removed all the unrequired parts from /etc/rc.initial.reboot:
#!/usr/local/bin/php-cgi -f <?php /* * reboot with notifications * * part of pfSense (https://www.pfsense.org) * Copyright (c) 2004-2013 BSD Perimeter * Copyright (c) 2013-2016 Electric Sheep Fencing * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate) * All rights reserved. * * originally part of m0n0wall (http://m0n0.ch/wall) * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* parse the configuration and include all functions used below */ require_once("config.inc"); require_once("functions.inc"); require_once("filter.inc"); require_once("captiveportal.inc"); $msg = sprintf(gettext("%s is rebooting now."), $g['product_label']); echo "\n" . $msg . "\n"; notify_all_remote($msg); system_reboot_sync(); echo "\n"; ?>
Then run it with a cronjob like:
30 1 * * * root /root/reboot.php
Or whatever time you want to reboot.
Steve
-
@stephenw10 you are a life saver
Many thanks, i would treat you a coffee rly!
it works perfectly fine done that twice
do i have to mark the conversation as solved somehow
dont know how pfsense forums work,sorry for the stupid questions.
-
No worries.
We don't have a formal 'mark as solved' arrangement. You may be able to edit the title in your first but that is time and reputation restricted. I can edit it for you if you want.
Steve
-
@stephenw10 Ye from what i see i cant edit it,if you can mark it for anyone with the same ''problem'' (mostly newbies) if they google it so they know it works
once again thank you!