- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to cp a DIR to DISK runing it using cro...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 09:39 AM
тАО05-13-2009 09:39 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 09:55 AM
тАО05-13-2009 09:55 AM
Re: script to cp a DIR to DISK runing it using cron job
This could be as simple as a crontab entry like:
0 17 * * cp -Rp /disk1/dir1 /disk1/dir2 /disk1/dir3 /disk2 && echo OK || echo FAILED
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 09:57 AM
тАО05-13-2009 09:57 AM
SolutionHaving said that, let's assume your "disk" is mounted on /new_disk filesystem and you want to copy the contetns of /data/dir1, /data/dir2 and /data/dir3 onto this /new_disk filesystem
you just create a script, let's say, /var/adm/datacopier.sh as follows:
#!/usr/bin/ksh
timestamp=`date | awk {'print $2 $3 $6'}`
for dir in /data/dir1 /data/dir2 /data/dir3
do
cp -rp ${dir} /new_disk/somedir/${dir}.${timestamp}
done
save and exit. Make sure it is executable by the person/group according to its file permissions.
then edit your crontab via command crontab -e and append this line
0 3 * * * /var/adm/datacopier.sh > /var/adm/datacopier.log 2>&1
Now, everyday at 3 AM, your directories will be copied to the destination disk and they will have a timestamp on them, in case you want to copy more than one day's worth.
Hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 10:09 AM
тАО05-13-2009 10:09 AM
Re: script to cp a DIR to DISK runing it using cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 10:15 AM
тАО05-13-2009 10:15 AM
Re: script to cp a DIR to DISK runing it using cron job
> thank you . now, will this overwrite the data daily?
In the simple script I suggested, yes. In Mel's method, no, since he appends a date (e.g. May132009) to each destination directory name.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 02:47 PM
тАО05-13-2009 02:47 PM