Thank you for your donation


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Idea: *** Feature Request ***
11th Apr, 2016, 10:07 PM
Post: #16
RE: *** Feature Request ***
There is a random delay to prevent server overload
Find all posts by this user
Quote this message in a reply
12th Apr, 2016, 03:29 AM
Post: #17
RE: *** Feature Request ***
I never knew that!

I'll see how it goes with different timings on different pis.
Find all posts by this user
Quote this message in a reply
12th Apr, 2016, 04:00 AM
Post: #18
RE: *** Feature Request ***
it is in file /etc/cron.daily/apt

Code:
# sleep for a random interval of time (default 30min)
# (some code taken from cron-apt, thanks)
random_sleep()
{
    RandomSleep=1800
    eval $(apt-config shell RandomSleep APT::Periodic::RandomSleep)
    if [ $RandomSleep -eq 0 ]; then
        return
    fi
    if [ -z "$RANDOM" ] ; then
        # A fix for shells that do not have this bash feature.
        RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 ))
    fi
    TIME=$(($RANDOM % $RandomSleep))
    debug_echo "sleeping for $TIME seconds"
    sleep $TIME
}

.....

# sleep random amount of time to avoid hitting the  
# mirrors at the same time
random_sleep

a is before x in alphabet, so apt is executed before xbian-daily-btrfs Smile
Find all posts by this user
Quote this message in a reply
12th Apr, 2016, 04:33 AM (This post was last modified: 12th Apr, 2016 04:34 AM by Nachteule.)
Post: #19
RE: *** Feature Request ***
Another reason for mystic delays is anacron, if installed (it is per default)

look into /etc/anacrontab
Find all posts by this user
Quote this message in a reply
12th Apr, 2016, 08:46 AM
Post: #20
RE: *** Feature Request ***
That's interesting and will take a while to get my head around it!

While this subject is here, is there any way to get anacron to only send me emails if there is a problem.

At the moment I use >/dev/null 2>&1 to stop the emails, but this means I might miss an important one with info I need. I have looked at man anacron, but don't see anything in there about it. Is the --report something that triggers the report to be sent? Is there another expression like --report the send ony on error?
Find all posts by this user
Quote this message in a reply
12th Apr, 2016, 09:08 PM
Post: #21
RE: *** Feature Request ***
Don't send error outputs (2>&1) to /dev/null, so you should only get mail on errors
Find all posts by this user
Quote this message in a reply
13th Apr, 2016, 04:15 AM
Post: #22
RE: *** Feature Request ***
Ever since I installed ssmtp I get daily, weekly and monthly emails from anacron, from each pi... 33 emails a week on average!

I'll let the emails throught and see if they are error ones, but I don't think they all contain error codes. This was also brought up in another thread here....

http://forum.xbian.org/thread-2929.html?highlight=anacron+email
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 01:47 AM
Post: #23
RE: *** Feature Request ***
(12th Apr, 2016 04:33 AM)Nachteule Wrote:  Another reason for mystic delays is anacron, if installed (it is per default)

look into /etc/anacrontab

I have searched the web and learnt some more about anacron and now think I have an idea as to why the backups are so late.

I have set the backup times between 2-4AM, but still they always have a time stamp of 9.30-11.00AM. Quite a big delay! - But now I understand that if anacron cannot complete a task at the assigned time, it will do so at the next opportunity.

This has got me thinking that the HDD's in the NAS go into powerdown mode (to save energy) when not in use for 30mins. I wonder if when they are sleeping, anacron can't wake them up to do the backups and so waits until the drives are woken up by some other activity during the morning.

Is there a way to test this theory by somehow waking up the drives just before the assigned time to write?
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 02:11 AM (This post was last modified: 17th Apr, 2016 02:12 AM by Nachteule.)
Post: #24
RE: *** Feature Request ***
(17th Apr, 2016 01:47 AM)Skywatch Wrote:  ...
[Is there a way to test this theory by somehow waking up the drives just before the assigned time to write?

Sure Smile

put file 0wakupnas into /etc/cron.daily folder with content like this
Code:
#!/bin/sh

ls -l /path-to-nas

if you want to wakeup drives before xbian-daily-btrfs runs, call it wakeupnas
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 02:50 AM
Post: #25
RE: *** Feature Request ***
Hi Nachteule,

Thank you for the adivce (and so quick too!) Smile

I have found a setting for 'wake on lan' in the server so have enabled that. If that fails I will try your method. It's all a learning curve for me here!

Cheers!
PS - All the updates and upgrades this week installed without any problems! Smile
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 03:06 AM
Post: #26
RE: *** Feature Request ***
Btw, do you already know the time when anacron will be started?

If not, please look into file /etc/cron.d/anacron
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 03:38 AM
Post: #27
RE: *** Feature Request ***
It has....

Terminal

30 7 * * * root test -x /etc/init.d/anacron && /usr/sbin/invoke-rc.d anacron start >/dev/null

So I guess, 07.30 - but doesn't it run all the time like cron? I am confused why anacron has a start time ???
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 03:45 AM
Post: #28
RE: *** Feature Request ***
(17th Apr, 2016 03:38 AM)Skywatch Wrote:  So I guess, 07.30 - but doesn't it run all the time like cron? I am confused why anacron has a start time ???

Because anacron is NOT a daemon and has to start once per day and when system boots
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 04:00 AM
Post: #29
RE: *** Feature Request ***
I had not seen that info. But does it matter when it starts as surely it must still do things the following day on time?

I will have to try some things and let you know if I find a solution!
Find all posts by this user
Quote this message in a reply
17th Apr, 2016, 08:34 PM
Post: #30
RE: *** Feature Request ***
This might seem a dumb question, but does this have to run from anacron. Can it be run with crontab?
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: