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

    Cron for WOL

    Scheduled Pinned Locked Moved General pfSense Questions
    24 Posts 7 Posters 5.7k 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.
    • K
      Khampol
      last edited by

      I have this.. (see pict). Normally it should wake my NAS everyday at 10.01.
      It never wake it… :(

      PS : My NAS wakes up if I do WOL manually.

      Region00.png
      Region00.png_thumb

      1 Reply Last reply Reply Quote 0
      • GertjanG
        Gertjan
        last edited by

        Putting the command in a cron is the final step.

        You tested the command from the console (SSH !) interface ?
        You did set up the NAS so it wakes up on when it receives the WOL packet ?
        Try also to wake it up from a windows PC using : https://sourceforge.net/projects/aquilawol/
        And even : try to wake up a Windows PC (settings have to be made in Windows and may be even the BIOS).
        When you can WOL "by hand" only then you automise (by cron).
        Check if the cron line is executed (see logs).

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • K
          Khampol
          last edited by

          Yes I know what mean WOL ! LOL!  ;D ;D ;D
          Years I do manually (by hand..).

          In Pfsense there is ALSO a function for WOL and "by hand" it works perfectly with my NAS.

          Thats why I am confused…

          Region01.png
          Region01.png_thumb

          1 Reply Last reply Reply Quote 0
          • I
            Issom
            last edited by

            Any update on this old topic? I am in the same boat as OP.
            I can manually start my unraid server and test Dell laptop from the WOL menu under Services but when I try to schedule the cron job or run the command manually I do not get the WOL protocol.
            I am monitoring the network traffic from Wireshark and I can see a protocol "WOL" when I run the wake up from the Services menu. When I try to run this command from cron or manually under Diagnostics> command prompt I only see TCP protocols broadcast.
            I am trying to wake both Unraid and Dell laptop.

            here is the commands I have been trying

            /usr/local/bin/wol (Mac address) This will broadcast to entire IP scheme
            /usr/local/bin/wol -v -i 172.x.x.x (Mac address) This only targets the exact IP of the machine

            Any help would be great
            Thanks
            Issom

            Kalle13K 1 Reply Last reply Reply Quote 0
            • GertjanG
              Gertjan
              last edited by

              Dono ....
              I just power down a PC next to me, and the I typed in

              /usr/local/bin/wol -v -i 192.168.1.7 b8:ac:6f:47:2d:b2
              

              The PC woke up immediately.

              Btw : I use the console access. That the one for 'real' commands.

              No "help me" PM's please. Use the forum, the community will thank you.
              Edit : and where are the logs ??

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

                It's usually because the user Cron runs with is not admin/root and somethings are subtly different. Default paths, permissions etc. You are using the complete path so that rules that out. Do you see any errors logged at that time?

                Steve

                1 Reply Last reply Reply Quote 0
                • Kalle13K
                  Kalle13 @Issom
                  last edited by Kalle13

                  @Issom Hi,
                  I know what you and OP mean. I have the same issue. It works manually but not via cron.
                  I want to wake up my server at 7 am but it won' t work. So after I realized it was not working I punshed the command in the command line and I got one error. It says that the host was not reachable. But direct after that I used the WOL service of the pfsense and it worked perfectly. (I am using pfSense 2.4.4. p3)
                  So was is the weird behaviour?

                  Best regards

                  "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

                  • Kinderzimmer Productions
                  1 Reply Last reply Reply Quote 0
                  • Kalle13K
                    Kalle13
                    last edited by

                    I've discovered a solution for this problem. Here you can find it. It' s a german post. Translated it says:
                    You have to activate the "static ARP" option at the "DHCP Static Mappings for this Interface" of the DHCP Server. Now you can wake your Host up with (direct from shell or via cron):
                    /usr/local/bin/wol -i IP MAC

                    Best regards

                    "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

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

                      Hmm, that should not be required. The machine doing the waking should not need to know anything but the MAC address.
                      Does it just not send the packet if you use the MAC only?

                      Steve

                      Kalle13K 1 Reply Last reply Reply Quote 0
                      • Kalle13K
                        Kalle13 @stephenw10
                        last edited by

                        @stephenw10
                        Sorry, I don't know. I didn' t used the wol command without the IP option.

                        "Jeder kocht mit Wasser, man kann das Binsenweisheit nenn`. Der unterschied zu dir ist, dass wir zwei kochen könn`"

                        • Kinderzimmer Productions
                        1 Reply Last reply Reply Quote 0
                        • P
                          pbshaan
                          last edited by

                          I bumped into the same problem. Sharing my findings for future visitors (tested with VLANs present - not sure if it matters).

                          Interface required:

                          Specifying the interface is optional, but without it the command doesn't work.

                          • wol xx:xx:xx:xx:xx:xx - executes, but no magic packet to device.
                          • wol -i 192.168.1.255 xx:xx:xx:xx:xx:xx - works.

                          Entries required in /etc/crontab:

                          • Manually add job definition to /etc/crontab - works, job triggers.
                          • crontab -e (as root user) - reports success, but job doesn't trigger. I also tried restarting cron after adding entries as another post suggested, but no luck.

                          So, edit /etc/crontab file directly and add your entry there. For the interface address, either machine IP or broadcast IP may be specified.

                          e.g.. /etc/crontab

                          ...
                          
                          # Wake up server at 6:30
                          30      6       *       *       *       root    wol -i 192.168.1.255 c0:3f:d5:66:XX:XX
                          
                          ...
                          
                          #
                          # If possible do not add items to this file manually.
                          
                          
                          GertjanG 1 Reply Last reply Reply Quote 1
                          • GertjanG
                            Gertjan @pbshaan
                            last edited by

                            @pbshaan said in Cron for WOL:

                            So, edit /etc/crontab file directly

                            😵

                            pfSense most simple package might be useful here.
                            Introducing the wol package :

                            bb18c5ad-908a-4447-8c3a-4621fcc7cc46-image.png

                            Now, your own crons will even be saved in the global pfSense config, making it a real set it and forget it thing.

                            Also, according to the "official manual" :

                            0d60bcc0-82f6-4e13-b8ba-ec4b10700f4a-image.png

                            If FreeBSD was installed on desktop type device with a single NIC, then this option is an option as there is only one NIC.
                            Our pfSense tends to have at least 2 NICs. So the option is qualified as "important".
                            I guess it's even a security issue if wol starts to send its notifications on all my xx interfaces.

                            No "help me" PM's please. Use the forum, the community will thank you.
                            Edit : and where are the logs ??

                            1 Reply Last reply Reply Quote 1
                            • Bob.DigB
                              Bob.Dig LAYER 8
                              last edited by Bob.Dig

                              Also had no luck getting wol with cron to work, the command is not even working in the GUI command prompt...

                              /usr/local/bin/wol -v -i 192.168.1.21 dx:50:99:92:11:e7
                              /usr/local/bin/wol dx:50:99:92:11:e7

                              Capture2.png

                              But working flawlessly via the pfSense >Services>Wake-on-LAN

                              GertjanG 1 Reply Last reply Reply Quote 0
                              • GertjanG
                                Gertjan @Bob.Dig
                                last edited by Gertjan

                                @bob-dig

                                I ping 192.168.1.2 : it's powered down.
                                I "wol" it.
                                It ping again and it replies ....

                                [2.5.2-RELEASE][admin@pfsense.local.net]/root: wol
                                wol: Too few arguments.
                                Try `wol --help' for more information.
                                [2.5.2-RELEASE][admin@pfsense.local.net]/root: ping 192.168.1.2
                                PING 192.168.1.2 (192.168.1.2): 56 data bytes
                                ^C
                                --- 192.168.1.2 ping statistics ---
                                3 packets transmitted, 0 packets received, 100.0% packet loss
                                [2.5.2-RELEASE][admin@pfsense.brit-hotel-fumel.net]/root:  wol -v -i 192.168.1.2 00:4e:01:ac:ca:9c
                                Waking up 00:4e:01:ac:ca:9c with 192.168.1.2:40000...
                                [2.5.2-RELEASE][admin@pfsense.local.net]/root: ping 192.168.1.2
                                PING 192.168.1.2 (192.168.1.2): 56 data bytes
                                64 bytes from 192.168.1.2: icmp_seq=2 ttl=128 time=0.255 ms
                                64 bytes from 192.168.1.2: icmp_seq=3 ttl=128 time=0.325 ms
                                64 bytes from 192.168.1.2: icmp_seq=4 ttl=128 time=0.333 ms
                                64 bytes from 192.168.1.2: icmp_seq=5 ttl=128 time=0.291 ms
                                ^C
                                --- 192.168.1.2 ping statistics ---
                                6 packets transmitted, 4 packets received, 33.3% packet loss
                                round-trip min/avg/max/stddev = 0.255/0.301/0.333/0.031 ms
                                

                                In the past, when wol was still a magic (pun intended) thing, there was a tool that you could run on the device to be waken up : it showes you that it's NIC did receive the magic wake up packets.
                                These packets are used to wake up the device, if it is able to do so, and if it was allowed to do (by driver and or BIOS settings).

                                No "help me" PM's please. Use the forum, the community will thank you.
                                Edit : and where are the logs ??

                                Bob.DigB 1 Reply Last reply Reply Quote 1
                                • Bob.DigB
                                  Bob.Dig LAYER 8 @Gertjan
                                  last edited by Bob.Dig

                                  @gertjan One difference might be that my NIC doesn't have an IP address, its only purpose it to wake up the PC.

                                  And again, it is working flawlessly via the GUI Services>Wake-on-LAN

                                  GertjanG 1 Reply Last reply Reply Quote 0
                                  • GertjanG
                                    Gertjan @Bob.Dig
                                    last edited by Gertjan

                                    @bob-dig said in Cron for WOL:

                                    And again, it is working flawlessly via the GUI Services>Wake-on-LAN

                                    GUI Services>Wake-on-LAN ?
                                    Aha, you mean https://pfsense.yourlocal.tld/services_wol.php.

                                    You had a look how "services_wol.php" does it's wol thing ?
                                    ( it used the wol command like you ;) )

                                    See here https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/services_wol.php - line 51.

                                    'wol' needs an IP ( ?) so it can determine the interface to be used..
                                    The interface has an IP, right ?

                                    When I used a fake IP, like 192.168.1.200 instead of 192.168.2, my "00:4e:01:ac:ca:9c" device didn't wake up.

                                    No "help me" PM's please. Use the forum, the community will thank you.
                                    Edit : and where are the logs ??

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

                                      What happens if you use the pfSense interface IP there? In the same segment as the target?

                                      Bob.DigB 1 Reply Last reply Reply Quote 0
                                      • Bob.DigB
                                        Bob.Dig LAYER 8 @stephenw10
                                        last edited by Bob.Dig

                                        @stephenw10 Doesn't work either and yes.

                                        If I try with putty I get this.

                                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol -v -i 192.168.1.1 d0:50:99:92:11:e7
                                        Waking up d0:50:99:92:11:e7 with 192.168.1.1:40000...
                                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol -v d0:50:99:92:11:e7
                                        /usr/local/bin/wol: Cannot send magic packet for 'd0:50:99:92:11:e7' to 255.255.255.255:40000: Permission denied
                                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root: /usr/local/bin/wol d0:50:99:92:11:e7
                                        /usr/local/bin/wol: Cannot send magic packet for 'd0:50:99:92:11:e7' to 255.255.255.255:40000: Permission denied
                                        [2.5.2-RELEASE][admin@pfSense.home.arpa]/root:
                                        
                                        

                                        But again, none of this worked.

                                        GertjanG 1 Reply Last reply Reply Quote 0
                                        • GertjanG
                                          Gertjan @Bob.Dig
                                          last edited by Gertjan

                                          @bob-dig

                                          If your "device without IP" ( serious ?? see below ) is some windows device, try this :

                                          https://www.depicus.com/wake-on-lan/wake-on-lan-monitor

                                          b5d92fac-bb97-4596-928d-944c68793f6e-image.png

                                          I had to indicate a port number like "40000" on both side so the command line works :

                                          wol -i 192.168.1.2 00:4e:01:ac:ca:9c -p 4000
                                          Waking up 00:4e:01:ac:ca:9c...
                                          

                                          The tool on the device, my PC, that it received the special pachet (5 times the device MAC as the data payload)

                                          See also the FreeBSD mn page for wol https://www.freebsd.org/cgi/man.cgi?query=wol&manpath=ports&sektion=1

                                          edit : a device in lower power mode doesn't have - use an IP(v4 or v6).
                                          It just listens to the incoming data stream, and knows how to detect if it's won MAC is present 5 times in a row. No processor power is needed.

                                          wol needs a IP or host just to so it can find out on what interface to use if it is "multi homed", like our pfSense. The actual IP shouldn't matter ......
                                          But .....
                                          I think © that our switches play an important role here. Switches are not hubs, so traffic isn't broadcasted any more.
                                          When I use the broadcast IP of my LAN, like :

                                          wol -i 192.168.1.255 -p 4000 00:4e:01:ac:ca:9c
                                          

                                          it worked, the Wake On Lan monitor on my PC showed the incoming magic packet.

                                          No "help me" PM's please. Use the forum, the community will thank you.
                                          Edit : and where are the logs ??

                                          Bob.DigB 1 Reply Last reply Reply Quote 2
                                          • Bob.DigB
                                            Bob.Dig LAYER 8 @Gertjan
                                            last edited by Bob.Dig

                                            @gertjan I want to use wol (not pattern match?) for this. I ended up using wol.exe on another Windows host together with windows tasksheduler to achieve what pfSense couldn't do for me. 🙂

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