LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   day anacron runs (https://www.linuxquestions.org/questions/linux-software-2/day-anacron-runs-4175558596/)

baldur_1 11-11-2015 11:12 AM

day anacron runs
 
i have a quick question i cant seem to find an answer for. is there a way to change the day ANACRON (not CRON as some people dont know the difference) runs its weekly stuff. currently it runs sunday. i would like it to run friday or is there a way to maybe set a cron.daily job to only run on friday?

thanks...

chrism01 11-11-2015 05:37 PM

The cron.daily dir (and the others) is there just for convenience.
Feel free to add the relevant job into the /etc/crontab file and set the timings to whatever you want.

baldur_1 11-11-2015 09:29 PM

yeah but does anacron run crontab...? if anacron does run crontab then it is no issue but i was under the understanding that it did not and anacron does not have a way to specify the day it is run from what i have seen. i dont mess around with cron too much so i am not really too knowledgible here...only what i have been able to gather over the last few hours...

chrism01 11-12-2015 05:44 AM

(Apologies if you already know/understand the following)

Can I just check; you do realise anacron is only for doing an extra run of jobs that should have run when the system was shutdown. They are run after a specified delay eg http://www.thegeekstuff.com/2011/05/anacron-examples/ after the system comes up.

The various cron dirs & crontab file(s) are for normal operation.

The anacron files have a totally different format to normal cron. You can make the first entry almost any integer, but some have special meanings; see example.


If you do know all this, can you explain in a bit more detail what you are trying to do and why.
Thx

michaelk 11-12-2015 07:17 AM

Depends on the distribution and have not looked if systemd works the same but cron typically runs anacron. Check your system cron jobs. In any case you should be able to change it to a regular cron job

baldur_1 11-13-2015 05:19 AM

okay, lets clarify what i am doing. i built a dvr with myth a bit ago, many a moon back. there is this annoying thing, when it first pulls the lineups, many tv shows that i am trying to record and many football games do not have the information like aqua teen and robot chicken and nearly all college football games, probably because they have not been decided or something i dont know, and it never grabs the new tv information when you just run mythfilldatabase. when i run mythfill --dd-grab-all it fills in those so i want that to be run on some kind of regular basis.

just by choice i decided i did not want to run dd-grab-all every night and plus i wasnt sure, even though i suspected that if i put --dd-grab-all into the set up line it would run, so i decided to add it as a cron script to run only on friday when i know most of the stuff is finally filled in and if i run it before mythfill usually runs, it will only run once.

so i first thought lets add it as a cron job because i could specify by day when it ran so i did and it would not run. then, after researching it appears that the cron jobs on ubuntu 14.04 are no longer run, anacron runs jobs. and i am fairly certain of that because both cron and anacron are set to run the cron.daily...files and the news ones i added never ran when i had them under the crontab file or under by user crontab.

so, at any rate, that lead me to the anacron stuff. i dont know a lot about it but i do now that it runs the jobs now AND, it runs after a reboot as mentioned but it also runs the regularly scheduled stuff but in the cron weekly, daily...stuff i cannot specifcy which day it runs and right now anacron runs on sunday and that is after all of the college games so, problem.

so i needed to move up when anacron runs weekly or get it to work some other way and i think i got it. i wrote a script and put it in cron.daily that checks the day of the week and when it is friday, it runs mythfilldatabase and when it is not friday, it exits. it ran on friday but i have not seen it exit yet on a not friday so i am not 100 sure it is working but it appears to be.

BUT, it would have been a lot simpler if i could have just added it to cron, not that it was overly complex writing that script but... so unless i am wrong, it appears to me that cron jobs are not being run rather anacron is running them so is cron still running jobs on ubuntu 14.04 (or more specifically mythbuntu)?

baldur_1 11-13-2015 05:20 AM

i did mark this as solved as a figured out how to get what i needed done but there is still a question...

michaelk 11-13-2015 05:41 AM

Quote:

25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
I assume your /etc/crontab looks something like the above. if anacron is not execuatable, run-parts is used to run the files in cron.daily, cron.weekly, and cron.monthly at 6:25 AM, 6:47 AM and 6:52 AM, respectively using cron.

In /etc/anacrontab, run-parts is used to run cron.daily 5 minutes after anacron is started, and cron.weekly after 10 minutes (once a week), and cron.monthly after 15 (once a month).

Within the cron.daily, weekly, and monthly directories ( /etc/cron.daily, etc.) there is a 0anacron file that sets the timestamps for anacron, so it will know they have been run, even if it didn't run them.

anacron is run on every startup, wake up, plug-in, and at 7:30 AM every day. You can change 7 to a 5 so it runs on Fri or if the box is on 24/7 then you can change it so cron runs.

47 6 * * 5 root run-parts --report /etc/cron.weekly

baldur_1 11-13-2015 08:28 AM

perfect, thanks. i havent found a good explantion of how everything works. that is an excellent one...now i understand.


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