Forum
[IDEA] *** Feature Request *** - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Others (/forum-24.html)
+--- Thread: [IDEA] *** Feature Request *** (/thread-3509.html)

Pages: 1 2 3


RE: *** Feature Request *** - Nachteule - 11th Apr, 2016 10:07 PM

There is a random delay to prevent server overload


RE: *** Feature Request *** - Skywatch - 12th Apr, 2016 03:29 AM

I never knew that!

I'll see how it goes with different timings on different pis.


RE: *** Feature Request *** - Nachteule - 12th Apr, 2016 04:00 AM

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


RE: *** Feature Request *** - Nachteule - 12th Apr, 2016 04:33 AM

Another reason for mystic delays is anacron, if installed (it is per default)

look into /etc/anacrontab


RE: *** Feature Request *** - Skywatch - 12th Apr, 2016 08:46 AM

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?


RE: *** Feature Request *** - Nachteule - 12th Apr, 2016 09:08 PM

Don't send error outputs (2>&1) to /dev/null, so you should only get mail on errors


RE: *** Feature Request *** - Skywatch - 13th Apr, 2016 04:15 AM

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


RE: *** Feature Request *** - Skywatch - 17th Apr, 2016 01:47 AM

(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?


RE: *** Feature Request *** - Nachteule - 17th Apr, 2016 02:11 AM

(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


RE: *** Feature Request *** - Skywatch - 17th Apr, 2016 02:50 AM

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


RE: *** Feature Request *** - Nachteule - 17th Apr, 2016 03:06 AM

Btw, do you already know the time when anacron will be started?

If not, please look into file /etc/cron.d/anacron


RE: *** Feature Request *** - Skywatch - 17th Apr, 2016 03:38 AM

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 ???


RE: *** Feature Request *** - Nachteule - 17th Apr, 2016 03:45 AM

(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


RE: *** Feature Request *** - Skywatch - 17th Apr, 2016 04:00 AM

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!


RE: *** Feature Request *** - Skywatch - 17th Apr, 2016 08:34 PM

This might seem a dumb question, but does this have to run from anacron. Can it be run with crontab?