- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- System Administration
- >
- Re: Log rotation daily
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
12-02-2009 07:13 PM
12-02-2009 07:13 PM
Log rotation daily
I would like to do a daily log rotation for the script attached. Anyone can help ?
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-02-2009 07:26 PM
12-02-2009 07:26 PM
Re: Log rotation daily
We can use cron.
# crontab -e
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-02-2009 07:29 PM
12-02-2009 07:29 PM
Re: Log rotation daily
The current script just run a single file and keeps appending to the same file daily.
It is not producing a daily file itself. That is what I intend to do.
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-02-2009 07:41 PM
12-02-2009 07:41 PM
Re: Log rotation daily
log_file=log_`date +%Y%m%d%H%M`_readSMS.txt
So this says that everytime the script runs, it will produce a new file like log_200912022232_readSMS.txt.
So, if you do not want new file to be created, you should remove `date +%Y%m%d%H%M` above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-02-2009 07:55 PM
12-02-2009 07:55 PM
Re: Log rotation daily
The objective is, Once the script runs, it produces a daily logfile. The logfile logrotates every day with the timestamp. There is no interference manually. Currently, the file just keeps on appending to the file produced.
FYI,the process is meant to run 24*7.
Do you get what I mean?
Regards
Feng Lin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-02-2009 08:46 PM
12-02-2009 08:46 PM
Re: Log rotation daily
You will have to restart the java process daily so that the line:
log_file=log_`date +%Y%m%d%H%M`_readSMS.txt
be effective.
otherwise, the system will continue logging to the same file as at the date/time it was launched.
If not feasible, you will have to write another script that backups the log file and truncates the current one.
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-04-2009 12:56 AM
12-04-2009 12:56 AM
Re: Log rotation daily
read this URL:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1259916930385+28353475&threadId=1326387
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
12-04-2009 08:48 AM
12-04-2009 08:48 AM
Re: Log rotation daily
OUTFILE=/path/to/logs/log_$(date +%Y%m%d%H%M)
after that run your app like this:
if [ "$my_process" = "" ]
then
nohup java $JAVA_JVM -Xms128m \
-Xmx128m -verbose:gc -XX:PermSize=64m \
-XX:MaxPermSize=64m -XX:SurvivorRatio=6 \
com.nsp.sms.batch.ReadSMSBatch \
1>> ${OUTFILE} 2>> ${OUTFILE} &
fi
...but you need to start it over every day to refresh the value of the variable $OUTFILE
Unix operates with beer.
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP