Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Move script.
azler
post Sep 2 2008, 06:03 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 11-August 08
Member No.: 13,606



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
Go to the top of the page
 
+Quote Post
michaelk
post Sep 2 2008, 07:24 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,799
Joined: 23-January 03
Member No.: 360



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.
Go to the top of the page
 
+Quote Post
azler
post Sep 3 2008, 02:23 PM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 11-August 08
Member No.: 13,606



Thanks, helped alot, sorted!
just need to see if tthe cron works!
Go to the top of the page
 
+Quote Post
michaelk
post Sep 3 2008, 05:22 PM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,799
Joined: 23-January 03
Member No.: 360



Make sure you include the entire path to your script in the crontab entry.
i.e.
30 01 * * * /path/to/script/mv_script
Go to the top of the page
 
+Quote Post
azler
post Sep 4 2008, 12:33 PM
Post #5


Whats this Lie-nix Thing?
*

Group: Members
Posts: 8
Joined: 11-August 08
Member No.: 13,606



do i need the ./path_to_script/script.sh
Go to the top of the page
 
+Quote Post
michaelk
post Sep 4 2008, 01:11 PM
Post #6


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,799
Joined: 23-January 03
Member No.: 360



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th November 2017 - 01:38 AM