Results 1 to 5 of 5

Thread: Rsync, .sh and Crontab

  1. #1
    Join Date
    Feb 2011
    Beans
    2

    Rsync, .sh and Crontab

    Hey,

    I'm currently trying to have crontab to automatically backup files from ramdisk. It works perfectly when I run it myself by simply cd:ing to scripts directory and type ./save_world.sh.

    The problem is, that crontab DOES (at least it looks like it) run that command every one minute. /var/log/syslog does show it executing that line every one minute without any errors.
    I'm currently very confused what I did wrong here. I have tried rebooting, fiddling with crontab line, tried sudo crontab -e but nothing seems to work.

    My script is called save_world.sh and it is located in /home/phoe/minecraft/rpg/
    Code:
    #!/bin/bash
    
    VOLATILE="/home/$USER/minecraft/rpg/world/"
    PERMANENT="/home/$USER/minecraft/rpg/world_storage/"
    
    rsync -r -t -v "$VOLATILE" "$PERMANENT"
    My crontab -e has one line and it is following:
    Code:
    * * * * * /home/phoe/minecraft/rpg/save_world.sh &> /dev/null
    I haven't determined any specific time yet, because I'm just trying to get it work first.

    Snippet from /var/log/syslog:
    Code:
    Feb 14 14:10:01 serv CRON[2276]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    Feb 14 14:11:01 serv CRON[2283]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    Feb 14 14:12:01 serv CRON[2324]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    Feb 14 14:13:01 serv CRON[2331]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    Feb 14 14:14:01 serv CRON[2338]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    Feb 14 14:15:01 serv CRON[2358]: (phoe) CMD (/home/phoe/minecraft/rpg/save_world.sh &> /dev/null)
    I would be eternally grateful if someone figures it out .

  2. #2
    Join Date
    Nov 2009
    Location
    East Anglia
    Beans
    415
    Distro
    Xubuntu

    Re: Rsync, .sh and Crontab

    Quote Originally Posted by phoe View Post
    Code:
    #!/bin/bash
    
    VOLATILE="/home/$USER/minecraft/rpg/world/"
    PERMANENT="/home/$USER/minecraft/rpg/world_storage/"
    
    rsync -r -t -v "$VOLATILE" "$PERMANENT"
    I don't think $USER will work here, try using the actual user name instead... or $LOGNAME.

    H
    Last edited by anglican; February 14th, 2011 at 02:00 PM.

  3. #3
    Join Date
    Aug 2007
    Location
    Hull, East Yorkshire, UK
    Beans
    302
    Distro
    Xubuntu Development Release

    Re: Rsync, .sh and Crontab

    You could try changing
    * * * * * /home/phoe/minecraft/rpg/save_world.sh &> /dev/null
    to which would give you some error logging info.
    * * * * * /home/phoe/minecraft/rpg/save_world.sh 2>> /home/phoe/error.txt
    Sony Vaio VGN-NS11J Laptop 2x Intel(R) Core(TM)2 Duo CPU T5800 @ 2.00GHz, 3 GB RAM, 320GB HD. My Linux Blog and My Folding@Home Stats

  4. #4
    Join Date
    Feb 2011
    Beans
    2

    Re: Rsync, .sh and Crontab

    Quote Originally Posted by anglican View Post
    I don't think $USER will work here, try using the actual user name instead... or $LOGNAME.

    H
    Oh my god, I can't believe it was that simple. Two days of crontab pissing me off, the real a**hole was my own script. I thought that because it runs fine manually, it must work with cron too, so I didn't even seek my problem from my script..

    Thank you a lot man, you don't know how happy I'm right now.

  5. #5
    Join Date
    Nov 2009
    Location
    East Anglia
    Beans
    415
    Distro
    Xubuntu

    Re: Rsync, .sh and Crontab

    Quote Originally Posted by phoe View Post
    Oh my god, I can't believe it was that simple. Two days of crontab pissing me off, the real a**hole was my own script. I thought that because it runs fine manually, it must work with cron too, so I didn't even seek my problem from my script..

    Thank you a lot man, you don't know how happy I'm right now.
    One of the main causes of problems with cron is the limited environment you get. Try running the following as a cron script and you'll see what I mean:
    Code:
    #!/bin/bash
    printenv > /home/$LOGNAME/printenv.txt
    H

Tags for this Thread

Bookmarks

Posting Permissions

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