- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Log rotation daily
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
тАО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
- 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
- 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
- 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
- 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
- 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
- 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
- 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.