You are not logged in.

#1 2005-05-07 08:40:09

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Local Mirror - Wiki - help please

Hello peoples,

I have read and followed the Wiki on having a local mirror  http://wiki2.archlinux.org/index.php/Local%20Mirror

My updates do not occur automatically, and I do not have the knowledge yet to fix this so I was wondering if there is a better way of doing this.  I have read Man:crond and crontab but am left a little confused as to how this can be incorporated into using the original script.  Also I would like to automate the time to 0200HRS.   Can somebody help me out please?   big_smile


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#2 2005-05-07 11:33:43

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: Local Mirror - Wiki - help please

It's not a good idea to automatically update your system, because config files may need updating. So if you want to do something automatically then use the download only option and let a script send an email when there are new packages, or something like that. Then manually update the systen when you can see what happens and can update the configs.

Offline

#3 2005-05-08 23:07:45

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Re: Local Mirror - Wiki - help please

Thankyou for your reply i3839,

From your answer, I can define more clearly what the issue is.  The updating I was refering to was only the ¨Current¨ and ¨Extra¨ database that I sync.  The script given in the wiki didn´t work for me so here is my version that works for me.

#!/bin/sh
rsync -avz --delete rsync.archlinux.org::ftp/current/os/i686/ /home/mirror/current/os/i686
rsync -avz --delete rsync.archlinux.org::ftp/extra/os/i686/  /home/mirror/extra/os/i686
# rsync -avz --delete rsync.archlinux.org::ftp/testing /mirror/
# rsync -avz --delete rsync.archlinux.org::ftp/unstable /mirror/

The two issues I have are:
1. the script does not run automatically via cron.daily/sync file, yet when I click on the sync.sh file it works. 
2. The updates occur at 0002hrs, which I would like to change to 0200hrs instead
cron.daily/sync:

!/bin/sh
SYNCLOGFILE="/var/log/sync.log"
SYNCLOCKFILE="/var/lock/sync.lock"

if [ -f $SYNCLOCKFILE ]; then
  # lock file already present, bail
  exit 1
fi

echo -n ">>> Sync log for " > $SYNCLOGFILE
date >> $SYNCLOGFILE

cd /home/mirror
touch $SYNCLOCKFILE
su - evan -c "/home/mirror/sync.sh" >> $SYNCLOGFILE
rm -f $SYNCLOCKFILE

Also, the sync.log and sync.lock files have not been created. Is this a permissions issue and if so how do I fix it?

Cheers


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#4 2005-05-08 23:55:43

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: Local Mirror - Wiki - help please

try this as root:

 crontab -e
00 02 * * *  /etc/cron.daily/sync

below whats already there.

If that doesn't work you've probably got the permisions wrong. In that case do:

chown root /etc/cron.daily/sync
chmod 744 /etc/cron.daily/sync

..and make sure you have crond added to your DAEMONS() array in /etc/rc.conf

Offline

#5 2005-05-09 02:35:04

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Re: Local Mirror - Wiki - help please

Excellent Penguin,

Thankyou!!  That is exactly what I was after.  I will let you know if this works .....err........tomorrow!   lol

Cheers


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#6 2005-05-09 21:30:54

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Re: Local Mirror - Wiki - help please

By looking at /etc/log/sync.log it appears to have worked.  Both files were created, and when I try to manually invok the /home/mirror/sync.sh file there seems to be no movement on my eth0 monitor 

I am confused by this command tho.

su - evan -c "/home/mirror/sync.sh" >> $SYNCLOGFILE

what does it do?  Also does this mean that /home/mirror/sync.sh should be owned by root or by user (evan)?

Cheers


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#7 2005-05-09 22:06:30

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: Local Mirror - Wiki - help please

from:

su - evan -c "/home/mirror/sync.sh" >> $SYNCLOGFILE

I gather /etc/cron.daily/sync calls on /home/mirror/sync.sh to work properly, and logs the output into your log file ( >> $SYNCLOGFILE).
Also,  /home/mirror/sync.sh should be owned evan and probably chmoded 744, hence su - evan -c "/home/mirrors/sync.sh".

Did that script run once or twice last night?

Offline

#8 2005-05-09 22:32:56

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Re: Local Mirror - Wiki - help please

Hi Penguin,

Only once -  well there was only one entry in the file.

The root# crontab -e command looks like this

#
# DO NOT EDIT THIS FILE MANUALLY!! USE crontab -e INSTEAD.
#

# <minute> <hour> <day> <month> <dow> <command>


01 * * * *  /usr/sbin/run-cron /etc/cron.hourly
02 00 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly

0       0        *       *       *       /usr/bin/archstats -u
0       2       *       *       *       /home/mirror/sync.sh
0       2       *       *       *       /etc/cron.daily/sync
~
~
"/tmp/crontab.27412" 15L, 407C                

I thought of deleting the /home/mirror/sync.sh line, as the /etc/cron.daily/sync file should now do this automatically. I will wait for your response before I do though.

  I really want to learn more about writing scripts.  What would you suggest I should start studying?
I appreciate your help with this  big_smile

Cheers


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#9 2005-05-09 22:53:13

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: Local Mirror - Wiki - help please

Yeah I dont think you need the /home/mirror/sync.sh file in the crontab. I would just comment out tat line with a # and test it now instead of later. The only thing that would be different to test it now would be changing the /etc/cron.daily/sync entry to the minute  hour to at least one minute ahead of the current time (it checks the crontab every minute for changes) and the rest would be:
* * 1     
The one represents monday.
I dont know why you had to specifically add the path to the crontab becuase when you place a script in any of those cron.* folders, it should execute at the given time specified. Thats why I asked if it ran twice..You might as well move that script out of the cron.daily folder and into the /home/mirror as the other, that should work as well as long as you specify the new path.

As far as bash scripting goes, I don't really have a good source for you other than this. I've been wanting to find a good source my self regarding the if and for statements...

Let me know what happens with the crontab adjustment wink

Offline

#10 2005-05-09 23:42:42

aikidoist72
Member
From: Australia
Registered: 2005-04-15
Posts: 63

Re: Local Mirror - Wiki - help please

Before moving the files you suggested, I tried a little experiment.
root# crontab -e

17 09 * * * /usr/sbin/run-cron /etc/cron.daily

And alas it worked  :shock:

>>> Sync log for Tue May 10 09:17:00 UTC 2005

So I adjusted crontab -e to....

# <minute> <hour> <day> <month> <dow> <command>


01 * * * *  /usr/sbin/run-cron /etc/cron.hourly
0 02 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly

0       0        *       *       *       /usr/bin/archstats -u

I think Arch realised I had help from a professional and gave in!!!!  wink
If it fails in the future, I will do as you suggest.  In fact it sounds logical to do it anyway, as all the relevant info is in the same folder.  Thankyou for your help mate!! 

Cheers


Sitting quietly
Doing nothing
The grass grows
And the flowers bloom
All by themselves

Offline

#11 2005-05-10 00:05:16

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: Local Mirror - Wiki - help please

yarrr!

tongue

Offline

Board footer

Powered by FluxBB