- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to clean files
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-17-2011 07:29 AM
тАО05-17-2011 07:29 AM
I wanted to please help me create a script that allows me to empty the files located in the following path: / var/opt/hpsmc/avc/VM00726000-1-1/log clean them manually with the command cp / dev / null
clean up files in the directory are: sgsyncd.log, monitorsvcd.bak, monitorsvcd.log
Thanks for your help
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2011 07:36 AM
тАО05-17-2011 07:36 AM
Re: script to clean files
Consider something like:
#!/usr/bin/sh
cd var/opt/hpsmc/avc/VM00726000-1-1/log || exit
for FILE in sgsyncd.log, monitorsvcd.bak, monitorsvcd.log
do
cat /dev/null > ${FILE}
done
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2011 09:22 AM
тАО05-17-2011 09:22 AM
Re: script to clean files
cd /var/opt/hpsmc/avc/VM00726000-1-1/log
ls sgsyncd.log monitorsvcd.bak monitorsvcd.log | while read file
do
ls -l $file >> purge.log
> $file
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2011 09:52 AM
тАО05-17-2011 09:52 AM
Re: script to clean files
Doing a 'cd' and assuming that it places you where you want is asking for trouble!
If the change-directory fails, you are left where you began. If you began from '/' and Wilfred's script would ever so helpfully truncate every file in the root directory. Of course, no directory descent would occur, but...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-17-2011 10:20 AM