I have a program that makes png images in a folder, and ever 24 hours or so i want to move them to a new folder via cron job, how could this be done?
basicaly the format wants to be:
mkdir /home/test/*currect date*
mv -rf /home/test/*.png *current date (folder i just made)
cp -rf /home/orign/*.png /home/test
and i want it to basicaly do this process Every 24/7 via cron job.
Any one got any idea? i think i have the basics, but how would i get variable to make the folder as the current date? just by the server clock.
Az
Something like
mkdir /home/test/`date +%y%m%d`
You can also create a variable like
DATE=/home/test/`date +%y%m%d`
and use it for all commands.
Look at the date man pages to change the format as desired.
Thanks, helped alot, sorted!
just need to see if tthe cron works!
Make sure you include the entire path to your script in the crontab entry.
i.e.
30 01 * * * /path/to/script/mv_script
do i need the ./path_to_script/script.sh
If the . was not a typo then No. The . i.e. ./script.sh means run from current working directory. cron has a limited environment and so you need to use the complete path.
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)