Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: cron.hourly jobs

  1. #1
    badger fruit NNTP User

    Default cron.hourly jobs


    i want to create a simple script to backup using rsync a folder on PC1
    (suse 11) to PC2 (Windows XP) which can then be put into cron.hourly or
    cron.daily.

    The target folder is mounted by a fstab entry:-

    Code:
    --------------------

    //192.168.1.226/backup /home/badger_fruit/lan/backup cifs username=badger_fruit,password=mypassword,auto,uid=badger_fruit,gid=users,_netdev 0 0

    --------------------


    By using the command ...

    Code:
    --------------------

    rsync -avz /home/badger_fruit/data/photos/ /home/badger_fruit/lan/backup/

    --------------------


    ... it creates the files/folders/subfolders etc as expected (hoorah)
    BUT i get a message saying there was an error:-


    Code:
    --------------------

    bgrsvr-y:/etc/cron.hourly # rsync -avz /home/badger_fruit/data/photos/ /home/badger_fruit/lan/backup/

    sending incremental file list
    ./
    rsync: failed to set times on "/home/badger_fruit/lan/backup/.": Permission denied (13)
    Aquarium/
    CapeVerde/
    Christmas2008/
    Computers/
    GardenProject/
    LoftProject/
    Misc/
    School Photos/

    sent 4175 bytes received 47 bytes 8444.00 bytes/sec
    total size is 41067045 speedup is 9726.92
    rsync error: some files could not be transferred (code 23) at main.c(1031) [sender=3.0.2]
    bgrsvr-y:/etc/cron.hourly #

    --------------------


    I have checked that "everyone" has "full control" on the Windows share
    and that the folder is not in "read only" mode.

    The username and password provided in the fstab are also correct, if i
    do a manual cp, it will work without any such error.

    Any ideas from anyone please?


    --
    badger_fruit
    ------------------------------------------------------------------------
    badger_fruit's Profile: http://forums.opensuse.org/member.php?userid=2099
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  2. #2
    Malcolm NNTP User

    Default Re: cron.hourly jobs

    Quote Originally Posted by badger fruit
    i want to create a simple script to backup using rsync a folder on PC1
    (suse 11) to PC2 (Windows XP) which can then be put into cron.hourly or
    cron.daily.

    The target folder is mounted by a fstab entry:-

    Code:
    --------------------

    //192.168.1.226/backup /home/badger_fruit/lan/backup
    cifs
    username=badger_fruit,password=mypassword,auto,uid=badger_fruit,gid=users,_netdev
    0 0 --------------------


    By using the command ...

    Code:
    --------------------

    rsync
    -avz /home/badger_fruit/data/photos/ /home/badger_fruit/lan/backup/
    --------------------


    ... it creates the files/folders/subfolders etc as expected (hoorah)
    BUT i get a message saying there was an error:-


    Code:
    --------------------

    bgrsvr-y:/etc/cron.hourly # rsync
    -avz /home/badger_fruit/data/photos/ /home/badger_fruit/lan/backup/
    sending incremental file list
    ./
    rsync: failed to set times on "/home/badger_fruit/lan/backup/.":
    Permission denied (13) Aquarium/
    CapeVerde/
    Christmas2008/
    Computers/
    GardenProject/
    LoftProject/
    Misc/
    School Photos/

    sent 4175 bytes received 47 bytes 8444.00 bytes/sec
    total size is 41067045 speedup is 9726.92
    rsync error: some files could not be transferred (code 23) at
    main.c(1031) [sender=3.0.2] bgrsvr-y:/etc/cron.hourly #

    --------------------


    I have checked that "everyone" has "full control" on the Windows share
    and that the folder is not in "read only" mode.

    The username and password provided in the fstab are also correct, if i
    do a manual cp, it will work without any such error.

    Any ideas from anyone please?
    Hi
    Try running it as your user (create your own crontab), rather than root,
    that will ensure you keep ownership of the files.

    --
    Cheers Malcolm (Linux Counter #276890)
    openSUSE 11.1 x86 Kernel 2.6.27.7-4-default
    up 1 day 4:52, 3 users, load average: 0.07, 0.29, 0.49
    GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82


  3. #3
    badger fruit NNTP User

    Default Re: cron.hourly jobs


    malcolmlewis;1907689 Wrote:
    > Hi
    > Try running it as your user (create your own crontab), rather than
    > root, that will ensure you keep ownership of the files.


    an excellent idea, unfortunately, im a noob so don't know how
    there are only two users on the "source" pc, root and "badger_fruit",
    would i just change the ownership of the "/etc/cron.hourly/backup" file
    or move it somewhere else on the filesystem?

    (ps, sorry, im such a noob )


    --
    badger_fruit
    ------------------------------------------------------------------------
    badger_fruit's Profile: http://forums.opensuse.org/member.php?userid=2099
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  4. #4
    ken yap NNTP User

    Default Re: cron.hourly jobs


    Stuff in cron.hourly is always executed as root.

    If you want to run as some account, or even if you don't, you should
    put jobs in /etc/cron.d, because that separates it from the system jobs
    and it's easier to see that it should be retained across upgrades. The
    format is:

    > min hour day month weekday user command


    e.g. a file /etc/cron.d/backupjob

    > 2 2 * * * root /root/bin/dobackup


    Every morning at 0202, run /root/bin/dobackup as root

    To run as a different user, change the user field. But test that the
    user can indeed run the command. And remember that some environment
    variables will not be set, like $HOME, $DISPLAY, etc.


    --
    ken_yap
    ------------------------------------------------------------------------
    ken_yap's Profile: http://forums.opensuse.org/member.php?userid=221
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  5. #5
    badger fruit NNTP User

    Default Re: cron.hourly jobs


    thanks
    so to clarify

    if i create a simple text file in /home/badger_fruit/data, chown it to
    use badger_fruit

    called "backupfiles", contents are:-


    Code:
    --------------------

    #!/bin/sh
    rsync -avz /home/badger_fruit/data/photos/ /home/badger_fruit/lan/backup/

    --------------------


    chmod it to make it executable (eg chmod 555 backup)
    then create a job in cron.d, called "runbackup"

    the contents being:-

    Code:
    --------------------

    1 * * * * badger_fruit /home/badger_fruit/data/backupfiles

    --------------------


    that would work?
    (ie run at 01:00hrs every day as badger_fruit)

    how would i know this had run? would it dump output to
    /var/log/messages, or some other place?

    by the way, i ran it as badger_fruit and it "worked", well, it gave the
    same error messages but didn't complain about no permission to run this
    blah blah


    --
    badger_fruit
    ------------------------------------------------------------------------
    badger_fruit's Profile: http://forums.opensuse.org/member.php?userid=2099
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  6. #6
    ken yap NNTP User

    Default Re: cron.hourly jobs


    Actually at 1 minute past every hour.

    Output from the program, if any, gets mailed to the user specified. You
    can also divert it yourself.


    Code:
    --------------------
    1 * * * * badger_fruit /home/badger_fruit/data/backupfiles > /tmp/backup.log 2>&1
    --------------------


    The 2>&1 merges stderr output to stdout.


    --
    ken_yap
    ------------------------------------------------------------------------
    ken_yap's Profile: http://forums.opensuse.org/member.php?userid=221
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  7. #7
    Malcolm NNTP User

    Default Re: cron.hourly jobs

    Quote Originally Posted by ken yap
    Actually at 1 minute past every hour.

    Output from the program, if any, gets mailed to the user specified. You
    can also divert it yourself.


    Code:
    --------------------
    1 * * * * badger_fruit /home/badger_fruit/data/backupfiles
    > /tmp/backup.log 2>&1 --------------------



    The 2>&1 merges stderr output to stdout.
    Hi
    Also remember to use the full path to rsync eg /usr/bin/rsync or use
    the path statement at the begining.

    I always use my own crontab for stuff like this, just run crontab -e to
    create one. There are also some GUI tools for it as well, depends on
    your desktop.

    --
    Cheers Malcolm (Linux Counter #276890)
    openSUSE 11.1 x86 Kernel 2.6.27.7-4-default
    up 1 day 6:50, 4 users, load average: 0.02, 0.07, 0.13
    GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82


  8. #8
    badger fruit NNTP User

    Default Re: cron.hourly jobs


    ken_yap;1907722 Wrote:
    > Actually at 1 minute past every hour.


    ah har, that's actually better for me, they are family photos and after
    my recent disaster i need to ensure i have a good mirror!

    ken_yap;1907722 Wrote:
    >
    > Output from the program, if any, gets mailed to the user specified. You
    > can also divert it yourself.
    >
    > >

    Code:
    --------------------
    > > 1 * * * * badger_fruit /home/badger_fruit/data/backupfiles > /tmp/backup.log 2>&1

    --------------------
    > >

    >
    > The 2>&1 merges stderr output to stdout.


    your code sample above, would that just dump the messages from the
    program output into a file and then append each time it's run? because
    that is also fine, i can tail it if i want or open in
    nano/more/less/whatever.


    --
    badger_fruit
    ------------------------------------------------------------------------
    badger_fruit's Profile: http://forums.opensuse.org/member.php?userid=2099
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  9. #9
    badger fruit NNTP User

    Default Re: cron.hourly jobs


    well i tried it, i set it up to run 15 minutes past the hour each hour
    and it did work but didn't dump the output to a text file, it seemed to
    mail it to root; a few moments after it ran (and it did run, hoorah!) i
    was told "new mail in /var/mail/root"

    opened it and saw the output.

    is it possible to dump output into a file instead of mail?
    edit- i also saw i still got the same permission error, despite running
    as badger_fruit


    --
    badger_fruit
    ------------------------------------------------------------------------
    badger_fruit's Profile: http://forums.opensuse.org/member.php?userid=2099
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


  10. #10
    ken yap NNTP User

    Default Re: cron.hourly jobs


    Yes, the way I showed you. It should have been mailed to badger_fruit
    anyway so maybe you had not written out your changes or something else
    went wrong. If you want to append, change the > to >>.


    --
    ken_yap
    ------------------------------------------------------------------------
    ken_yap's Profile: http://forums.opensuse.org/member.php?userid=221
    View this thread: http://forums.opensuse.org/showthread.php?t=401642


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •