azler
Sep 2 2008, 06:03 PM
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
michaelk
Sep 2 2008, 07:24 PM
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.
azler
Sep 3 2008, 02:23 PM
Thanks, helped alot, sorted!
just need to see if tthe cron works!
michaelk
Sep 3 2008, 05:22 PM
Make sure you include the entire path to your script in the crontab entry.
i.e.
30 01 * * * /path/to/script/mv_script
azler
Sep 4 2008, 12:33 PM
do i need the ./path_to_script/script.sh
michaelk
Sep 4 2008, 01:11 PM
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.