- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Logrotate is failing
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
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
тАО07-13-2009 01:30 AM
тАО07-13-2009 01:30 AM
I'm unable to successfully use logrotate to rotate syslog.log files. The problem is that logrotate is always creating a syslog.log.1 file and won't continue to create successive syslog.log.2, syslog.log.3, ..., syslog.log.N files, and it's not compressing these files either. Here's my /opt/logrotate/etc/logrotate.conf file:
create
compress
rotate 10
# uncomment this if you want your log files compressed
# compress
# packages drop log rotation information into this directory
# include /opt/logrotate/etc
# no packages own wtmp -- we'll rotate them here
/var/adm/wtmp {
monthly
create 0664 adm adm
rotate 1
}
# cat syslog
/var/adm/syslog/syslog.log {
rotate 10
daily
create
ifempty
noolddir
compress
create 640 root root
postrotate
/bin/kill -HUP `cat /var/run/syslog.pid`
endscript
}
# cat maillog
/var/adm/syslog/mail.log {
rotate 5
weekly
compress
}
And in /var/spool/cron/crontabs/root I have this configuration:
00 9 * * * /opt/logrotate/bin/logrotate /opt/logrotate/etc/logrotate.conf
If I run logrotate with -v I get the following output:
reading config file /opt/logrotate/etc/logrotate.conf
reading config info for /var/adm/wtmp
reading config info for /var/adm/syslog/syslog.log
reading config info for /var/adm/syslog/mail.log
Handling 3 logs
rotating pattern: /var/adm/wtmp monthly (1 rotations)
empty log files are rotated old logs are removed
errors will be mailed to miguel.rentes@efacec.pt
rotating pattern: /var/adm/syslog/syslog.log after 1 days (10 rotations)
empty log files are rotated old logs are removed
errors will be mailed to miguel.rentes@efacec.pt
rotating pattern: /var/adm/syslog/mail.log weekly (5 rotations)
empty log files are rotated old logs are removed
From here I can see that logrotate is removing my old logs, but I can't seem to understand why because I'm telling it to rotate 10 files in logrotate.conf.
Do you have any suggestions why this is happening? I also want to compress all log files but this is not happening either (gzip is in /usr/contrib/bin which is on the PATH).
Best regards and thanks in advance,
Miguel Rentes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 01:37 AM
тАО07-13-2009 01:37 AM
Re: Logrotate is failing
This isn't in the default path for cronjobs.
How do you tell logrotate that you want to use gzip and where it is?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 01:44 AM
тАО07-13-2009 01:44 AM
Re: Logrotate is failing
From the man page I can read:
compress
Old versions of log files are compressed with gzip. See also nocompress.
I didn't know I have to include any option to tell logrotate where to find gzip, I assumed it would find it from the PATH. The verbose output is not explicit either on this matter. So, how can I tell logrotate to use gzip? Isn't gzip used by default? And what about logrotate not rotating 10 times syslog.log?
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 02:11 AM
тАО07-13-2009 02:11 AM
Re: Logrotate is failing
It can't if you are using cron and don't explicitly set it.
Have you tried executing the command from your shell:
/opt/logrotate/bin/logrotate /opt/logrotate/etc/logrotate.conf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 02:14 AM
тАО07-13-2009 02:14 AM
Re: Logrotate is failing
But how can I configure logrotate to use gzip then? If I run:
/opt/logrotate/bin/logrotate /opt/logrotate/etc/logrotate.conf
I get no output. If I run
/opt/logrotate/bin/logrotate -v /opt/logrotate/etc/logrotate.conf
I get the following output:
reading config file /opt/logrotate/etc/logrotate.conf
reading config info for /var/adm/wtmp
reading config info for /var/adm/syslog/syslog.log
reading config info for /var/adm/syslog/mail.log
Handling 3 logs
rotating pattern: /var/adm/wtmp monthly (1 rotations)
empty log files are rotated old logs are removed
errors will be mailed to miguel.rentes@efacec.pt
rotating pattern: /var/adm/syslog/syslog.log after 1 days (10 rotations)
empty log files are rotated old logs are removed
errors will be mailed to miguel.rentes@efacec.pt
rotating pattern: /var/adm/syslog/mail.log weekly (5 rotations)
empty log files are rotated old logs are removed
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 02:16 AM
тАО07-13-2009 02:16 AM
Re: Logrotate is failing
But did it do what it was suppose to do to the logfiles?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-13-2009 02:20 AM
тАО07-13-2009 02:20 AM
Re: Logrotate is failing
This is what I have in /var/adm/syslog:
ls -al
total 18208
dr-xr-xr-x 2 bin bin 8192 Jul 13 09:00 .
drwxr-xr-x 15 adm adm 8192 Jul 5 16:31 ..
-rw-r----- 1 root root 85707 Jul 5 08:45 OLDsyslog.log
-r--r--r-- 1 root root 7271 Jul 13 11:03 mail.log
-r--r--r-- 1 root root 118835 Jul 13 08:32 mail.log.1
-rw-r----- 1 root root 82 Jul 13 10:14 syslog.log
-rw-r----- 1 root root 39 Jul 12 09:00 syslog.log.1
-rw-r----- 1 root root 9057037 Jul 7 14:44 xferlog
In this folder there should be compressed files and 3 syslog.log files because I started using logrotate last Friday and I'm telling logrotate to rotate in daily basis. What can be wrong?
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 02:20 AM
тАО07-15-2009 02:20 AM
Re: Logrotate is failing
I've checked my e-mail ang received this message:
"
Subject: errors rotating logs
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
sh: gzip: not found.
errors occured while rotating /var/adm/syslog/syslog.log
failed to compress log /var/adm/syslog/syslog.log.1
"
This points out that cron doesn't know where gzip is (which is in /usr/contrib/bin). I've changed my crontab to include this line at the top of /var/spool/cron/crontabs/root:
"PATH=/sbin:/usr/sbin:/usr/bin:/usr/contrib/bin:/usr/local/bin"
but when I stopped and started cron I got in my mail this message:
"
Your crontab file has an error in it.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/contrib/bin:/usr/local/bin
unexpected symbol found
This entry has been ignored.
"
So, can anyone tell me how to configure cron to have the path to gzip in PATH?
Best regards,
Miguel Rentes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 03:29 AM
тАО07-15-2009 03:29 AM
SolutionI'm glad that failed as expected. :-)
>I've changed my crontab to include this line at the top of /var/spool/cron/crontabs/root:
>how to configure cron to have the path to gzip in PATH?
Ack!
You change your command part of the entry:
(All one long line.)
00 9 * * * PATH=/sbin:/usr/sbin:/usr/bin:/usr/contrib/bin:/usr/local/bin /opt/logrotate/bin/logrotate /opt/logrotate/etc/logrotate.conf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 04:00 AM
тАО07-15-2009 04:00 AM
Re: Logrotate is failing
cron for Linux has a default PATH
Not so in HP-UX
Two choices:
1) set the PATH statement, preferably very early in your script.
2) Use full path for commands.
The second method is a problem if OS updates relocate the binaries and you don't wish to spend a lot of time porting your scripts.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2009 05:02 AM
тАО07-15-2009 05:02 AM
Re: Logrotate is failing
crontab(1) has a stripped down default path: PATH=/usr/bin:/usr/sbin:.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2009 08:51 AM
тАО07-17-2009 08:51 AM
Re: Logrotate is failing
Putting the PATH environment variable did solve my problem! I now have a working logrotate that rotates and compress my logs.
Thank you very much!
Best regards,
Miguel Rentes