: Cron force unzip file I have the following cron echo "*** Get the new ZIP file ***" /usr/bin/wget -t inf -nH -N -c --progress=dot --reject=zip --mirror --timestamping --timeout=60 --waitretry=60
I have the following cron
echo "*** Get the new ZIP file ***"
/usr/bin/wget -t inf -nH -N -c --progress=dot --reject=zip --mirror --timestamping --timeout=60 --waitretry=60 --no-passive-ftp --directory-prefix=/var/www/vhosts/mydir --ftp-user=xxx --ftp-password=xxx ftp://xxx.xxx.be/xxx.zip
echo "*** Cool now unzip the file please. ***"
unzip -o /var/www/vhosts/mydir/xxx.zip
everything works perfect from terminal
However if i make a cron job out of it the zip file gets downloaded but i can't seem to unzip the file and i get the following error's
*** Start *** Cool now unzip the file please. ***
Archive: /var/www/vhosts/mydir/xxx.zip
checkdir error: cannot create 012
unable to process 012/.
checkdir error: cannot create 025
unable to process 025/.
checkdir error: cannot create 027
unable to process 027/.
checkdir error: cannot create 031
unable to process 031/.
checkdir error: cannot create 031
unable to process 031/xxx/xx.jpg.
checkdir error: cannot create 031
unable to process 031/xxx/xx.jpg.
checkdir error: cannot create 053
unable to process 053/xxx/xx.jpg.
checkdir error: cannot create 053
unable to process 053/xxx/xx.jpg.
Is there a way i can force to create directory or overwrite existing files?
More posts by @Pierce454
2 Comments
Sorted by latest first Latest Oldest Best
Check that the $PATH is the same for both 'crontab' and the terminal. (If not, change it).
If you are getting permission problems, then you need to run the cron job as a user that has permissions to read and write in that directory. For example you could run the cron job as root.
There are at least two ways to run a cron job as root. In the first you can log in as root on the command line and then edit the root crontab with the command crontab -e Then paste the script you are running in there like this
00 00 * * * /opt/myscript/myscript.sh
The second way is to create a crontab file here /etc/cron.d/myscript with contents like this
root 00 00 * * * /opt/myscript/myscript.sh
Notice if you do it this way you have to prepend the user that will run the command.
Rather than running as root it would be better to choose a less powerful user and give them permissions to read and write in /var/www/vhosts/mydir. Lets say you want to do this with user bob. Issue the following commands to give bob ownership and read/write permission.
chown -R bob /var/www/vhosts/mydir
chmod -R o+rw /var/www/vhosts/mydir
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.