Jump to content

Scheduled tasks not following internal time?


Recommended Posts

hansolo77
Posted (edited)

Just got home from work.. Emby Server did NOT complete any scheduled tasks today.  I found in the logs from last night that it did set the appropriate trigger times, but checking the log for today, nothing was "fired".  Also strange is that the server (Emby) appeared to be doing SOME task (mostly Trakt with errors) like every 30 minutes, even though the computer SHOULD have been asleep all day.  Regardless, I think the idea that going into standby is what is causing the problem.  Emby seems to be forgetting any scheduled tasks that aren't set to run on an interval.

 

server-63598957559.txt

 

This is the log that recorded today's activities.  I'm a little concerned about the trakt errors.  It looks like it's trying to sync information that doesn't exist in their database, but I'm not sure how to resolve that.  It's a different issue though I'm not gonna worry about it just now.  For right now though, I think figuring out why Emby is ignoring tasks is more important.  I had a thought.. The log shows a specific date and time that the scheduled tasks are being "triggered", but also says something like "Which is in xxxxxx minutes".  Perhaps this timer only runs when the computer is awake?  Like, when it's asleep for xxxx minutes, it doesn't subtract that once it awakens?  So if the server is using a minute timer rather than a specific set time, that would explain it.  This also makes sense that it would use a timer because that's what you would want to use for intervals (every x hours, etc).  But for specific times it needs to use something other than a timer.

 

In any case, I'm going to take the next beta to see if anything fixes this problem and the other one.

Edited by hansolo77
Posted

Are the times in the log right?

hansolo77
Posted

The times were correct.  I tried erasing all the times then set new ones.  Rather than running at 10 after/etc.. I set everything to run at exactly 11:00 am.   I also noticed that if I just put "11:00", it auto sets it to AM.  If I put "11:00 pm" it makes a 2nd task for 11:00 am rather than pm.  The only way to get PM is by putting it at "23:00".  So that was an interesting experiment too.  But for the morning, either way of achieving it should work as both methods created tasks for the am.

Posted

so the times are correct, 22 hours away from the time of the log entry, but the log only covers 17 hours so i can't really tell what happened after that.

hansolo77
Posted

Yeah sorry about that.  I thought the logs for just yesterday up to the point where it should have happened was sufficient.  Here are the logs I have in my /logs folder, all zipped up.

 

logs.zip

 

There are a few extra logs in there because I was testing various methods of restarting the server via remote desktop, non-remote (locally), with the taskbar icon, etc, to try and see if I could come up with something else as to why the server isn't fully restarting (see other thread!).  So those logs are in there as well.  I haven't manually started the tasks yet, so they still show they haven't ran now for 2 days.  These logs should also show where I had erased the old times and created new ones for 11:00 (I had hoped maybe the tasks were just corrupted or something, and maybe making new ones would fix it.. it didn't).

Posted

can you give an example?

hansolo77
Posted

An example of which part? 

 

The times?  I erased them all and set them all to 11:00am. 

 

The restart methods?  I tried (via remote desktop) to restart using the button in the admin website, and by using the right-click on the taskbar icon and selecting Restart.  I also tried those methods by connecting directly to the computer (not via remote desktop) with the same results.

 

I'm not sure what you're looking for.

 

I'm leaving for a sleep study, so I'm not going to be home tonight to test further.  I'm off work tomorrow though so I'll be able to test more stuff then.

hansolo77
Posted (edited)

So I had a thought.  Maybe the reason it's not running is because I'm not logged in?  I seem to recall this being an issue and one reason you'd want to use the service rather than the tray icon.  Am I on the right track?  When I reboot the computer (or start it up from a cold boot), Emby isn't running.  The computer is on, but none of my clients can connect.  It only starts up if I remote desktop into the computer.  So the thought occurred last night while I was in my sleep study that maybe I need to be logged in for the tasks to run.  I was really tired when I got home this morning and went to bed.  I overslept though.  I wanted to be awake early enough so I could get logged into the computer by 11:00am to see if that was the "trick".  So, unfortunately, I didn't get logged in until around 11:30.  However, it wouldn't have made any difference anyway, since Emby wasn't running.  This is exactly the problem I'm having in the other thread.  I'm not sure when it stopped running, since I wasn't home.  Apparently though, it happened AFTER finally running a scan.  It shouldn't have.  But here is the evidence:

 

FNJqBRN.jpg

 

So it ran last night around 7:35.  This is way wrong.  I'm not sure where it got the idea to run at that time.  So maybe my idea of the "need to be logged in to work" doesn't matter after all.  I'm going to experiment today though.  I'm going to delete that "scan library" task and recreate a new one to run at 12:00 (noon) and stay logged in to see if it runs.  Then I'm going to recreate it again to run at 12:30 but NOT be logged in, to see if runs then.

 

EDIT:  Found these in the log from last night:

2016-05-18 19:24:34.6604 Info TaskManager: DailyTrigger fired for task: Scan media library
2016-05-18 19:24:34.6604 Info TaskManager: DailyTrigger fired for task: Check for application updates
2016-05-18 19:24:34.6604 Info TaskManager: Queueing task SystemUpdateTask
2016-05-18 19:24:34.6604 Info TaskManager: Executing Check for application updates
2016-05-18 19:24:34.6604 Info TaskManager: Queueing task RefreshMediaLibraryTask
2016-05-18 19:24:34.6604 Info TaskManager: DailyTrigger fired for task: Check for plugin updates
2016-05-18 19:24:34.6604 Info TaskManager: Queueing task PluginUpdateTask
2016-05-18 19:24:34.6604 Info HttpClient: HttpClientManager GET: https://api.github.com/repos/MediaBrowser/Emby/releases
2016-05-18 19:24:34.7541 Info TaskManager: Executing Scan media library
2016-05-18 19:24:34.7541 Info TaskManager: DailyTrigger fired for task: Chapter image extraction
2016-05-18 19:24:34.7541 Info TaskManager: Queueing task ChapterImagesTask
2016-05-18 19:24:34.7541 Info App: Validating media library
2016-05-18 19:24:35.4904 Info TaskManager: DailyTrigger fired for task: Refresh people
2016-05-18 19:24:35.4904 Info TaskManager: Queueing task PeopleValidationTask
2016-05-18 19:24:35.9956 Info TaskManager: DailyTrigger fired for task: Clean Database
2016-05-18 19:24:35.9956 Info TaskManager: Queueing task CleanDatabaseScheduledTask
2016-05-18 19:24:36.9847 Info TaskManager: DailyTrigger fired for task: Configuration Backup
2016-05-18 19:24:36.9847 Info TaskManager: Queueing task ScheduledBackupTask
2016-05-18 19:24:37.9854 Info TaskManager: DailyTrigger fired for task: Download missing subtitles
2016-05-18 19:24:37.9854 Info TaskManager: Queueing task SubtitleScheduledTask
2016-05-18 19:24:39.0060 Info TaskManager: Daily trigger for Check for application updates set to fire at 5/19/2016 11:00:00 AM, which is 935.349899941667 minutes from now.
Edited by hansolo77
Posted

To use the tray icon you must be logged in to your machine, yes. Emby cannot handle that part for you.

hansolo77
Posted

The 12:00 test worked.. if I'm logged in the scheduled task ran fine.

 

So I wonder, if I have to be logged in, if there is a way to to login to the desktop via a scheduled task on the server, without having to physically do it on my work machine prior.  I guess running as a service would eliminate this problem entirely.  But the downside to that is the the inability to restart the server after automatic update installs.  Were there ever any plans to update the restart plugin to function with the service as well as the tray icon?

Posted

you can use a windows scheduled task to login i would think.

 

So just to recap, Emby not broken after all :) ?

Posted

You could just configure the machine to automatically login at startup...

hansolo77
Posted (edited)

I dunno.  I thought it worked fine before.  But regardless, that doesn't explain why it would run an 11:00am task at 7:35pm.  That's what prompted all this. 

 

How can I set a scheduled task to auto login?  I have a task to wake the server up and to execute the task as a specific user, but how would I create a task to just log in?

 

EDIT:  Just had another thought as I was about to test something else... I'm not LOGGING OUT when I close my remote desktop.  I'm just closing it, it gives me a popup reminder that the applications are still running and I can resume work by simply logging back in.  So I don't see what the difference is between having the connection up and running, vs just having it running without SEEING it.

Edited by hansolo77
Posted

That's outside of Emby so I am not sure, but maybe you can do that with windows scheduled tasks.

 

The fact that it ran at 7:35pm is not necessarily a problem - the task might have run for another reason besides the daily trigger, like the file system monitor for example.

hansolo77
Posted (edited)

I'm narrowing it down.  I think I know what's happening.  When the computer is ON and running (having previously R/D'd) then Emby runs it's tasks like it's supposed to.  Whether I'm R/D'd or not.  The problem occurs when the system goes into standby.  I don't think this is an Emby issue though.  See, I was reading some tech documentation about Windows Server 2012 just now, and apparently when the computer goes into standby, it logs out the users.  So when the computer resumes out of standby, it's like sitting at a screen waiting for a user to login.  So if a user isn't logged in, Emby doesn't run it's tasks.  So I guess this is another situation that can be avoided if you just use the service rather than a tray icon.  The troubling thing is, why doesn't it automatically resume from it's previous state (of being logged in already), but rather prompt for a login.  I'll have to check how my power options are configured.  I might have it set to act like that.  I also looked for a way to automatically log in on power up (and presumably resume) so I'm going to experiment with that next.

 

EDIT - Maybe that idea is wrong.  :(  It's working like it's supposed to now.  I created a new task time to run at 2:20.  I then closed down the remote desktop.  I then forcibly told the server to go into standby, then sent it the WOL command.  I waited until a few minutes had gone by past 2:20 and logged into to see if it had ran, and it's running now.  So I guess that wasn't the case either.  <grumble>  I don't get it.

Edited by hansolo77
Posted

Our challenge is educating users so that they know what Emby is responsible for and what it is not. On page 1 of this thread, you were convinced there was an Emby problem and you were ready to leave:

nothing seems to be working right.

That's a difficult situation for us because it can lead to us taking away entire features like the DailyTrigger just so that you can avoid turning them on and then struggling with them. Hopefully I can find a way to get that information through to users so that we don't just have to deprecate the daily trigger altogether.

hansolo77
Posted (edited)

Yeah, I understand.  It's just been a rough battle trying to narrow down what the cause is.  I'm still not 100% certain it's a login problem from sleep.  I'm trying another experiment now.  I configured Windows to NOT prompt for a user login when powering on.  I then created another task to run at 2:40pm.  I then reboot the computer.  Hopefully, it's logged in automatically and has everything running.  Prior to rebooting, I checked my Power options to see whether it was set to prompt for a user login after resuming.  It WAS, so I disabled that too.  I guess the only way to test this now is to wait and see if Emby did it's 2:40 task here in a couple minutes.

 

EDIT - Didn't work.  My computer failed to login to the desktop and start Emby.  So I'm not sure what happened there.  I'm going to try going back to the SERVICE version of the server now.

Edited by hansolo77
hansolo77
Posted (edited)

UPDATE - I disabled the Taskbar Icon in the Emby settings, and set the Service to run AUTOMATIC, and configured the username to login with.  I then set a new task to run and restarted the computer.  Waited about 10 minutes then logged in.  Once I got the desktop up, Emby started loading.  I checked the services and the service was running too.  So now I have 2 instances running (taskbar and service).  I double checked the Emby settings and the task bar option was UNCHECKED.  However, it still ran.  New problem?  Also, it didn't run the new scheduled task either (probably because the taskbar wasn't running).

Edited by hansolo77
Posted

No, not new problem. The server has an option to create a startup shortcut, and unchecking the option will cleanup that shortcut. But if at some point a shortcut was ever created through some other means, Emby Server will not be able to clean that up. Just for a point of feedback, if the "run at startup" option were not there at all, would you still have considered that to be an Emby problem? We could just remove it completely in order to prevent any possible frustration from occurring.

 

Anyway it's not possible to have 2 instances. Even if you have two processes running, they'll figure it out and one of them will close, typically whichever was the 2nd one.

hansolo77
Posted

Well, with the whole "server not restarting" thread, that's been a bit of a problem.  They DON'T shut down automatically.  Although I do know what you mean because in that issue, it's typically the 2nd instance starting up before the 1st ends and it closes because of it.

 

I don't remember if I created a new shortcut or not.  I thought about that and looked.  But Windows Server doesn't actually have a "Startup" folder in the Start Menu, so there's nothing to remove.  I might have manually created a registry key, but I don't remember where.  I'll have to look around.

 

I will say one thing.  Using the service rather than the taskbar icon (even though the taskbar is running still) has definitely resolved the scheduled tasks issue this thread is all about.  I've created numerous new tasks, and tried all the various experiments I had tried previously (like cold booting, forcing into standby and manually waking up, logging in, not logging it, etc) and they all work.  Now I just need to figure out why the tray icon is loading up too once I log in.

 

As for your feedback... honestly I think the only reason I even tried to use the taskbar version was because I wanted to be able to use that automated restart plugin.  I liked the idea of having it all completely automated.  Emby would check daily for a new version and install it, then reboot every day about 15 minutes after checking/installing.  It worked good for a while, then something happened and it all became a mess and stopped working.  That's what prompted me to start this thread.  Going to a service ONLY mode seems to fix all the issues regarding the daily time tasks though.  The only downside now is there is no longer the automation of installing updates.  BUT.. since the shutdown/restart function isn't quite working right now either, that hardly seems like a problem I need to worry about.  So I think having a service only option would definitely make things easier.. and just get rid of that restart plugin.  Either that, or re-code the restart plugin to work with the service instead (and still remove the taskbar icon option).

 

Going forward, I still need to see if I can find where the taskbar is autostarting and eliminate that, then I'll see if the "bug" I'm having is maybe also related to the tray icon.  I forget, is the restart button in the admin dashboard able to work with the service?  I think that was another issue actually.  I seem to recall having to go in and stop/start the service to get the new updates working.  Could be wrong though.  But that'd be an issue for the other thread.

Posted

I haven't tried it, but ask in that thread and others in the know may help out.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...