LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-23-2016, 11:07 PM   #1
ForumBot
LQ Newbie
 
Registered: Jul 2016
Posts: 25

Rep: Reputation: Disabled
How can jobs be run at specific reoccurring dates without assuming the computer is never asleep?


I would like to find a way to execute tasks on specific reoccurring dates, for example send a message every April Fool's Day, without assuming the machine is running and not sleeping. Edit: by this, I mean if the system is sleeping or not running, the command should be executed once it starts running again.

The at command fails at this, as it does not seem to allow a command to be executed reletedly and endlessly (unless you use some sort of self-replicating program).

Cron fails, as it assumes the system is constantly up.

Anacron fails, as it can only schedule jobs to run within an interval, but I don't think you can specify a single day in a year to run.

Fcron seems to fail, as though it can execute tasks even if the computer was shit down during the time they were supposed to be executed, it does not seem to execute jobs if the computer is sleeping during the time they are supposed to be executed. Edit: actually, fcron can run tasks that were supposed to be run when the computer was in sleep mode, but it seems to take 15-60 minutes after the computer is awoken before they are executed.

One potential workaround would be to run rtcsleep to make the computer awake during a specific period, run all jobs during that time, and then during that time make fcron run rtcsleep as root to make it re-awake the next time jobs need to be run. Also, I think if the computer is a laptop, the laptop must be left open when the tasks are supposed to run in order for it to not go to sleep again immediately when rtcsleep wakes it. Would this work and is there an easier way?

Last edited by ForumBot; 07-24-2016 at 07:50 PM.
 
Old 07-24-2016, 07:47 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
Check at and cron daemon.
 
Old 07-24-2016, 09:19 AM   #3
ForumBot
LQ Newbie
 
Registered: Jul 2016
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Keruskerfuerst View Post
Check at and cron daemon.
As discussed in my post, I already considered at and cron, but neither suited my needs. Do you mean something else?
 
Old 07-24-2016, 09:36 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by ForumBot View Post
I would like to find a way to execute tasks on specific reoccurring dates, for example send a message every April Fool's Day, without assuming the machine is running and not sleeping.

The at command fails at this, as it does not seem to allow a command to be executed reletedly and endlessly (unless you use some sort of self-replicating program). Cron fails, as it assumes the system is constantly up.
Sorry, this is just not true, and makes no sense. If the system is DOWN...how, exactly, does cron run a job? Same with at...if the system is down, it obviously won't run.

Not sure what you're asking for, but both cron and at will most CERTAINLY run a job on a specific date/time, if the system is up. If you mean something like "I scheduled the job for 8 AM on the first, but the system was down then, and I WANT it to run when the system comes back up", that's a job for your script. Turn your script into a daemon: http://blog.terminal.com/using-daemo...your-programs/

..and have it check the date/time upon execution. If the system is down at 8 am, and reboots at 9, the script will run, and see it's AFTER the runtime...and you can then make it execute, then go back to sleep and/or reschedule itself to run again/do whatever. There are ways around this, and that's only one.
 
1 members found this post helpful.
Old 07-24-2016, 09:44 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,592

Rep: Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880Reputation: 5880
I don't know of an easier way except for leaving the computer running. I don't know of any way to trigger something specific without a clock or timer running.

Last edited by michaelk; 07-24-2016 at 09:45 AM.
 
Old 07-24-2016, 10:10 AM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
This is why there's software as a service. Let someone else run your computer and they keep it always up. You might ask microsoft, by default windows 8 would boot at 3am and do stuff, even when the computer was turned off. But there's no way to guarantee that as the computer could be unplugged. Or unbootable after a windows update. Or it could be running linux. I suppose systemd will have a solution for this sooner or later.

Even if cron or at could do it, the admin can turn off said things. I do. The last thing I want is a process starting in the middle of a boss fight and degrading performance plus upping the latency.
 
Old 07-24-2016, 08:10 PM   #7
ForumBot
LQ Newbie
 
Registered: Jul 2016
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post

Not sure what you're asking for, but both cron and at will most CERTAINLY run a job on a specific date/time, if the system is up. If you mean something like "I scheduled the job for 8 AM on the first, but the system was down then, and I WANT it to run when the system comes back up", that's a job for your script. Turn your script into a daemon: http://blog.terminal.com/using-daemo...your-programs/

..and have it check the date/time upon execution. If the system is down at 8 am, and reboots at 9, the script will run, and see it's AFTER the runtime...and you can then make it execute, then go back to sleep and/or reschedule itself to run again/do whatever. There are ways around this, and that's only one.
Yes, I want it to run when the system comes back up. Sorry for the lack of clarity.

I could turn it into a daemon, but that comes with the potential for memory leaks and the daemon getting killed, so I suspect there is an easier way.
 
Old 07-25-2016, 07:42 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by ForumBot View Post
Yes, I want it to run when the system comes back up. Sorry for the lack of clarity. I could turn it into a daemon, but that comes with the potential for memory leaks and the daemon getting killed, so I suspect there is an easier way.
Again, this makes little sense. *ANY* program/shell-script/cron/at job can be killed, period...there's no more (or less) chance of a daemon getting killed than any other program. Also, if you are talking about a program or shell script that you already HAVE, why would daemonizing it suddenly create 'memory leaks'????

There are a TON of ways to do this:
  • Have your script run every hour, and look for a file that it creates. Check the date/time, and run if greater-than/less-than some variable.
  • Have it run at each system startup, again looking for a file. If present/not present, do something.
  • Have it run at system startup period.
  • Have you script run at startup, then sleep for whatever interval you choose.
  • ....be creative and think of about a thousand other ways....
 
Old 07-25-2016, 09:44 AM   #9
ForumBot
LQ Newbie
 
Registered: Jul 2016
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Again, this makes little sense. *ANY* program/shell-script/cron/at job can be killed, period...there's no more (or less) chance of a daemon getting killed than any other program. Also, if you are talking about a program or shell script that you already HAVE, why would daemonizing it suddenly create 'memory leaks'????
I'm not very knowledgeable about it, but I think that if you run a task periodically via cron or the like, any memory it uses during its execution will be freed once it is finished, decreasing the risk of memory leaks. I think a daemon would never finish executing unless it was killed, which I presume would make it more vulnerable to memory leaks. Also, answers here say that daemons are more vulnerable to memory leaks.

And I don't think daemons would be more likely to get killed; I just heard that the ability for daemons to restart themselves is unreliable.

Quote:
Originally Posted by TB0ne View Post
There are a TON of ways to do this:
  • Have your script run every hour, and look for a file that it creates. Check the date/time, and run if greater-than/less-than some variable.
  • Have it run at each system startup, again looking for a file. If present/not present, do something.
  • Have it run at system startup period.
  • Have you script run at startup, then sleep for whatever interval you choose.
  • ....be creative and think of about a thousand other ways....
The second, third, and forth suggestion would not work for me, as they would not run, or at least not run soon enough, if my system is always up or up for a very long time.

But I think I will use some variation of the first option. Would it be okay to make it call at to execute itself in the future to keep it running?
 
Old 07-25-2016, 09:52 AM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,553

Rep: Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946Reputation: 7946
Quote:
Originally Posted by ForumBot View Post
I'm not very knowledgeable about it, but I think that if you run a task periodically via cron or the like, any memory it uses during its execution will be freed once it is finished, decreasing the risk of memory leaks. I think a daemon would never finish executing unless it was killed, which I presume would make it more vulnerable to memory leaks. Also, answers here say that daemons are more vulnerable to memory leaks.
Wrong, mostly. While daemons do reside on the system vs. only running when called (cron), the amount they take up is minuscule. The daemonizing process is not 'more vulnerable' to memory leaks..those are a function of YOUR program. If your program doesn't leak, the daemon won't either. While they CAN be, you're making it out to be more of a problem than it is.
Quote:
And I don't think daemons would be more likely to get killed; I just heard that the ability for daemons to restart themselves is unreliable.
Wrong. If that was the case, hardly any *nix systems would be running. The big advantage of a daemon is that they DO restart themselves with great reliability, when that functionality is enabled.
Quote:
The second, third, and forth suggestion would not work for me, as they would not run, or at least not run soon enough, if my system is always up or up for a very long time.
But I think I will use some variation of the first option. Would it be okay to make it call at to execute itself in the future to keep it running?
Since you still haven't said exactly what it is you are trying to accomplish, and on what interval, there is no way for anyone here to guess. As said, those are things you COULD do, among thousands of other choices. Unless you provide details, there's not much we can tell you past very broad suggestions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any boot Distros for specific jobs!! tysonmax20042003 Linux - Software 2 07-21-2009 05:47 PM
A script to watch the news "TF1" JT of specific dates ? frenchn00b Linux - General 0 08-07-2007 06:42 AM
I'm looking for software to manage computer repair jobs HGeneAnthony Linux - Software 3 08-29-2006 01:15 AM
Reoccurring display information malluen SUSE / openSUSE 0 08-23-2005 05:56 PM
How to send print jobs to 2nd computer? jhecht Linux - Software 2 08-23-2004 08:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration