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

    [Solved] pfSense Cron reboot with email-telegram notification

    General pfSense Questions
    3
    9
    1.3k
    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.
    • A
      Armor-64
      last edited by stephenw10

      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

      84f6c7f2-2d57-4dcb-9cb6-44353eaf484f-image.png

      i made a php(part copy from original one from menu)

      70654f76-5f5e-437c-b29e-49847d86ca6e-image.png

      If any info you want i am willing to assist,

      thnx!

      NogBadTheBadN A 2 Replies Last reply Reply Quote 0
      • NogBadTheBadN
        NogBadTheBad @Armor-64
        last edited by NogBadTheBad

        @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?

        Andy

        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          You would need to call the appropriate php script to trigger the notifications as you show.

          Have you tried running that?

          A 1 Reply Last reply Reply Quote 0
          • A
            Armor-64 @stephenw10
            last edited by

            @stephenw10 d69325c8-3260-4713-a068-7b32c4e9b019-image.png

            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 😵

            1 Reply Last reply Reply Quote 0
            • A
              Armor-64 @Armor-64
              last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator
                last edited by

                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

                A 1 Reply Last reply Reply Quote 1
                • A
                  Armor-64 @stephenw10
                  last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • stephenw10S
                    stephenw10 Netgate Administrator
                    last edited by

                    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

                    A 1 Reply Last reply Reply Quote 0
                    • A
                      Armor-64 @stephenw10
                      last edited by

                      @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!

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