• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

simple cron job error !!PLEASE HELP!!

W

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:

/var/www/vhosts/mywebsite.com.au/httpdocs/

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?
 
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:

#!/bin/sh
#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

ok..

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.
 
Back
Top