Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Crontab not working
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Crontab not working

xprotoceptxprotocept Member
edited September 2011 in Help

Hey

I made a Backup script (sh) for backing up my TS3 server and uploading it to a remote FTP Server, but i tried to do it as a cron-job for each day, but it just doesn't work

Can someone help me? I'm using CentOS 5 32 Bit

Anyone who is interested in the script, here it is

#!/bin/sh
DATE=`/bin/date +%Y%m%d`
TIME=`/bin/date +%H`
zip -r ts3-$DATE.$TIME.zip ts3
USERNAME="xxxxxx"
PASSWORD="xxxxxx"
SERVER="xxxxxx"
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
mput ts3-$DATE.$TIME.zip
quit
EOF
echo Backup saved to Remote FTP Server!
echo Removing local Backup now
rm ts3-$DATE.$TIME.zip
echo Done!

Thanks

Comments

  • When running from cron PATH is very limited, so not every command will work.

    You are using ts3 as a directory (not an absolute path), are you sure you are running cronjob in the directory which contains ts3 directory?

    Why do you echo in cronjob? where you want to see it?

    Check /var/log/cron* for information.

  • is cron... running? lol

  • yeah cron us running

    i'm using this: 45 10 * * * * /home/backup.sh

  • What exactly does "just doesn't work" mean? Does that mean cron is not trying to run your script at the specified time? Does it mean cron runs the script, but it has permission errors? Does it mean cron runs the script, but /bin/sh doesn't parse the script properly? Does it mean /bin/sh runs the script but the script fails somewhere?

  • MozaiMozai Member
    edited September 2011

    If there's a problem with the script being launched, crond is supposed to send STDERR to the mailbox of the owner of the job.

    First: check to make sure crontabs are running.

    00,10,20,30,40,50 * * * * * /bin/echo "ping."

    That should send you an email message every ten minutes. If not, either the cronjob isn't launching, or the stdout/stderr is going to the wrong mailbox.

  • Err. People need to learn how to debug their scripts. Like @rajprakash has said, what does it mean by "just doesn't work"? Does the script work when you run off the command line? Also what would be the cwd when your cron job runs? Because you certainly assume that it is somewhere as ts3/ is a relative directory.

    Moreover, if anything fail in cron it should generate an email to whoever running the script. Do you have mail set up (check your /etc/aliases for example) so you can receive the error message?

  • Got it fixed


    Installed Debian, and now it's all working

  • Now that's an interesting way of solving the problem. Hail to Debian, at last! ;-)

    Thanked by 1ksx4system
  • @LowEndAdmin,

    People need to learn how to debug their scripts

    Welcome to my world....

  • xprotocept said: Installed Debian, and now it's all working

    Okay... I thought that only happens on Windows land? Something is not working correctly? Just reinstall Windows...

  • ...or get a Mac. :)

    Thanked by 1dmmcintyre3
  • I was thinking the same thing ... just reinstall and it "works" ?

  • yomeroyomero Member
    edited September 2011

    drmike said: @LowEndAdmin,

    People need to learn how to debug their scripts

    Welcome to my world....

    Agree... ¬_¬

    rajprakash said: I was thinking the same thing ... just reinstall and it "works" ?

    Windows solution, you know... xD

    Edit: Oh, LEA already said that Q_Q

  • One of the support forums that I help out on has Start a New Thread form that for the post content has prefilled text making suggestions on what to include with people's asking for help. (Does that make sense?) Stuff like check logs, what's your os?, any errors, etc.

    You have no idea how often people who ask questions either just write around that or delete it and put in their "I need help. Please help me" with no data.

Sign In or Register to comment.