Scheduled Tasks (Delayed / Cron-style) not working, but instant tasks are.
-
Hi,
I am unable to get a host to turn on using a wake-on lan scheduled task. It does not work with cron-style tasks, or with the single scheduled task option. Instant tasks work fine.
Important Information:
Edit: Scheduled deploys also do not work.
The host does have an image associated with it.
I have tried to schedule the task at the host level and at the group level to no avail.
This host was originally being managed with another FOG server. It’s now being managed by a new FOG server. To achieve that, I created a new VM (the FOG server is a VM, the host isn’t), and installed CentOS and FOG from scratch, then captured the image from the host on the new server.
I’ve set the correct timezone in the FOG GUI and in php.ini.
I’ve tried a cron style task at * * * * * (doesn’t work either).
I’ve run the database maintenance commands.
The output of the bash date command is correct.
The PHP time is correct I think, I tested it by creating a .php file that does “echo date(‘Format String’, time());”
The database time is correct when I enter the query SELECT CURRENT_TIME();
Thanks in advance for any help.
-
Please unplug-wait 10 seconds-replug the target computer then test WOL. Confirm if that works or not.
Justification: If the wol works from an off but just plugged in state but does not power on from a windows shutdown/sleep state then its Windows do it to you and not anything with FOG or the computer. Windows shutdown/sleep is not a powered off state but a deep sleep state (S4/S5). In this sleep state the computer can not be woke up by WOL. One remidy is to turn off fast startup in windows. This works most but not all of the time. Disabling S4/S5 states in the bios will (if your hardware mfg supports turning them off) resolve the issue, but may impact windows startup time.
Edit: reference https://docs.microsoft.com/en-us/windows/win32/power/system-power-states I should have checked first its only S5 state where WOL isn’t functional. WOL is supported in S4 state. Plus I learned of a new state G3 state (mechanical off). Search WOL in the link above for the explanation.
-
Thanks for the suggestion but that didn’t work.
I unplugged the device for 10 seconds, then sent an instant WOL, which booted, so I unplugged it again for 10 seconds, then scheduled one for 2 minutes later, and it didn’t boot, so it appears to be the same behaviour.
-
@hj104 OK so what we now know is that Windows is not messing with you so here, so we should look within the FOG code to understand what is different. Sometimes you have to find where the problem isn’t to find where it is.
-
@hj104 said in Scheduled Tasks (Delayed / Cron-style) not working, but instant tasks are.:
then sent an instant WOL
Did you send the WOL by itself or just an instant task?
-
@Sebastian-Roth Hi, I sent an instant task.
-
How about the most relevant question of all, maybe I missed it, what version of fog are you running?
-
Also what does the task scheduler log show?
-
I’m running 1.5.7.
Here is the output of /opt/fog/log/fogscheduler.log
[root@localhost log]# tail -n 10 fogscheduler.log [01-15-20 12:46:50 am] * No tasks found! [01-15-20 12:47:50 am] * No tasks found! [01-15-20 12:48:50 am] * No tasks found! [01-15-20 12:49:50 am] * No tasks found! [01-15-20 12:50:50 am] * No tasks found! [01-15-20 12:51:50 am] * No tasks found! [01-15-20 12:52:50 am] * No tasks found! [01-15-20 12:53:50 am] * No tasks found! [01-15-20 12:54:50 am] * No tasks found! [01-15-20 12:55:50 am] * No tasks found!
At 12:36pm, prior to taking that output, I scheduled a delayed task for 12:38pm. As you can see, nothing appeared in the log.
Note that those times around midnight are definitely incorrect, I was not working on it at that time and the server was off at that time as I shutdown my computer over night. Despite that, I would still expect that scheduling a cron-style task at * * * * * would work regardless of any time discrepancies right?
Thanks
-
@hj104 Chances are the time is based on UTC time, as FOG_TZ_INFO (in fog settings) is likely unset at the moment.
I’m guessing here, that the task scheduler appears to be checking every minute?
-
@hj104 I have just tested on a fresh install and both delayed and cron-style work perfectly fine. My log looks like this:
cron-style / * * * * *
[01-18-20 10:31:05 pm] * No tasks found! [01-18-20 10:32:05 pm] * No tasks found! [01-18-20 10:33:05 pm] * No tasks found! [01-18-20 10:34:05 pm] * 1 task found. [01-18-20 10:34:05 pm] * Task run time: Sat, 18 Jan 2020 22:34:00 +0000 [01-18-20 10:34:05 pm] * Found a task that should run. [01-18-20 10:34:05 pm] - Is a host based task. [01-18-20 10:34:05 pm] - Unicast task found! [01-18-20 10:34:05 pm] - Host hostname [01-18-20 10:34:06 pm] - Tasks started for host hostname! [01-18-20 10:35:05 pm] * Sending 1 wake on lan request. [01-18-20 10:35:05 pm] * 1 total mac attempting to wake up.
delayed task set to 22:37 (10:37 PM):
[01-18-20 10:35:06 pm] * No tasks found! [01-18-20 10:36:05 pm] * Sending 1 wake on lan request. [01-18-20 10:36:05 pm] * 1 total mac attempting to wake up. [01-18-20 10:36:06 pm] * 1 task found. [01-18-20 10:36:06 pm] * Task run time: Sat, 18 Jan 2020 22:37:00 +0000 [01-18-20 10:37:06 pm] * Sending 1 wake on lan request. [01-18-20 10:37:06 pm] * 1 total mac attempting to wake up. [01-18-20 10:37:06 pm] * 1 task found. [01-18-20 10:37:06 pm] * Task run time: Sat, 18 Jan 2020 22:37:00 +0000 [01-18-20 10:37:06 pm] * Found a task that should run. [01-18-20 10:37:06 pm] - Is a host based task. [01-18-20 10:37:06 pm] - Unicast task found! [01-18-20 10:37:06 pm] - Host hostname
Note that those times around midnight are definitely incorrect, I was not working on it at that time
While I am not sure this is causing the problem I would definitely try to start looking at this first. You said you have checked timezone in the FOG GUI. Do we talk about TZ INFO in FOG Configuration -> FOG Settings -> General Settings? After changes here you need to restart the scheduler service (
systemctl restart FOGScheduler
).The PHP time is correct I think, I tested it by creating a .php file that does “echo date(‘Format String’, time());”
Did you run this on the command line or on the web server? If it was command line that might be different to what you get on the web server because configuration can differ. So please try this code on the FOG web server:
<?php $tz = new DateTimeZone('Europe/Berlin'); // use your timezone identifier here! $d = new DateTime('now', $tz); echo $d->format('m-d-y g:i:s a'); ?>
-
Hi,
Both delayed and cron-style scheduled tasks are now working for me.
After reading Sebastian’s reply, I ran the provided PHP code on the web server and the time was correct.
I then double checked TZ INFO in FOG Configuration -> FOG Settings -> General Settings and it was indeed set to the correct time zone, but I pressed update anyway and then I ran
systemctl restart FOGScheduler
.As soon as I ran that command, my test computer turned on. Here is the log output from that time:
[01-20-20 11:31:06 am] Interface Ready with IP Address: 127.0.0.1 [01-20-20 11:31:06 am] Interface Ready with IP Address: 127.0.1.1 [01-20-20 11:31:06 am] Interface Ready with IP Address: 192.168.20.17 [01-20-20 11:31:06 am] Interface Ready with IP Address: localhost.localdomain [01-20-20 11:31:06 am] * Starting TaskScheduler Service [01-20-20 11:31:06 am] * Checking for new items every 60 seconds [01-20-20 11:31:06 am] * Starting service loop [01-20-20 11:31:06 am] * 3 tasks found. [01-20-20 11:31:06 am] * Task run time: Fri, 17 Jan 2020 12:38:00 +1100 [01-20-20 11:31:06 am] * Found a task that should run. [01-20-20 11:31:06 am] - Is a host based task. [01-20-20 11:31:06 am] - Unicast task found! [01-20-20 11:31:06 am] - Host cg1new [01-20-20 11:31:06 am] - Tasks started for host cg1new! [01-20-20 11:31:06 am] * Task run time: Thu, 16 Jan 2020 11:11:00 +1100
The time in the log is also correct now. I’ve never ran
systemctl restart FOGScheduler
before but I have restarted my FOG server multiple times since setting TZ INFO.My only question now is whether restarting the server has the same effect on the FOGScheduler service as running
systemctl restart FOGScheduler
?Thanks for the assistance.
-
@hj104 said in Scheduled Tasks (Delayed / Cron-style) not working, but instant tasks are.:
My only question now is whether restarting the server has the same effect on the FOGScheduler service as running systemctl restart FOGScheduler?
I am pretty much sure this can be answered with yes. Sorry but I have no idea why this was wrong in the first place but working now. Seems like you have not changed anything.