1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

simple cron job error !!PLEASE HELP!!

Discussion in 'Plesk for Linux - 8.x and Older' started by willgnosis, May 5, 2010.

  1. willgnosis

    willgnosis Guest

    i am very sorry if this has been asked before... i'm sure it has.. but i have searched all over the net looking for an answer and i still cant find it... so somebody pleeeeease help me!

    I have a really simple cron job script like this:

    cd /var/www/vhosts/

    tar -cvzf /backup/myhttpdocs-backup-`/bin/date +\%Y\%m\%d`.tar mywebsite.com.au/httpdocs/

    when i run this manually it works fine
    but when i run it from my ROOT user in Plesk as a cron task is always creates a file that is just 45 bytes. Why doesn't it work... I am running it as a root user.. so surely i must have permission to access the files?!!! Its driving me nuts.

    oh yeah and PS... my /backup folder is chmod 777

    the full path to the directory i want to backup is:


    and again... IT WORKS when i log in as root user using ssh. So why wouldn't it qork when i run it as a cron task?
  2. willgnosis

    willgnosis Guest

    OK... heres an update

    I forgot to mention before that I was actually running the cron task via a script file, so my actually cron task command looked like this:

    /bin/bash /bin/backupscript.sh >/dev/null 2>&1

    and the file looked like this:

    #backup website weekly
    #delete copies older than one 10 days

    mysqldump --user=admin --password=mypassword --all-databases > /backup/mysqlall-`/bin/date +\%Y\%m\%d`.sql

    tar -cvzf /backup/mywebsite.com-backup-`/bin/date +\%Y\%m\%d`.tar /var/www/vhosts/mywebsite.com/httpdocs


    so the weird thing was that the mysqldump commanded WORKED perfectly ... but the tar command just produced a file that was 45 bytes. for some reason the tar command cant find the files.. or doesn't have permission.. which i dont understand if I am running the cron task as root user .. how can it not have permission?

    I just tried to make a new cron task as root... with just the direct command:

    tar -cvzf /backup/mywebsite.com-backup-`/bin/date +\%Y\%m\%d`.tar /var/www/vhosts/mywebsite.com/httpdocs

    and wow..! it works...

    so now i got it working but i still dotn get why it wont exectute the command when it is another file?

    if anyone can explain that it would be great.