Author Topic: Logrotate domlogs  (Read 25123 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Logrotate domlogs
« on: February 19, 2019, 03:02:40 PM »
Hi

how to setup a logrotate of the domlogs in logrotate manager ?

Offline
*
Re: Logrotate domlogs
« Reply #1 on: February 19, 2019, 11:16:29 PM »
I'd like some assistance with this as well. As a test I have done the following (though NOT for files in the Apache/domlogs folder - trying to get one working first) Testing with PHP-FPM log files:

  • In CWP -> File Management -> Logrotate Manager created a new Conf file - FPM56. Verified that the file was created at /etc/logrotate.d
  • Added simple content as follows
    /opt/alt/php-fpm56/usr/var/log/php-fpm.log {
    weekly
    rotate 1
    notifempty
    missingok
    }
  • From the CWP logrotate interface clicked on the Run Now button for the new entry
  • Received an error: lines must begin with a keyword or a filename (possibly
  • From shell ran logrotate -df /etc/logrotate.d/FPM56
  • Received the following:
  • reading config file /etc/logrotate.d/FPM56
    error: /etc/logrotate.d/FPM56:1 lines must begin with a keyword or a filename (possibly in double quotes)
    Allocating hash table for state file, size 15360 B
    Handling 1 logs
    rotating pattern: /opt/alt/php-fpm56/usr/var/log/php-fpm.log  forced from command line (1 rotations)
    empty log files are not rotated, old logs are removed
    considering log /opt/alt/php-fpm56/usr/var/log/php-fpm.log
      log needs rotating
    rotating log /opt/alt/php-fpm56/usr/var/log/php-fpm.log, log->rotateCount is 1
    dateext suffix '-20190220'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    renaming /opt/alt/php-fpm56/usr/var/log/php-fpm.log.1 to /opt/alt/php-fpm56/usr/var/log/php-fpm.log.2 (rotatecount 1, logstart 1, i 1),
    renaming /opt/alt/php-fpm56/usr/var/log/php-fpm.log.0 to /opt/alt/php-fpm56/usr/var/log/php-fpm.log.1 (rotatecount 1, logstart 1, i 0),
    renaming /opt/alt/php-fpm56/usr/var/log/php-fpm.log to /opt/alt/php-fpm56/usr/var/log/php-fpm.log.1
    removing old log /opt/alt/php-fpm56/usr/var/log/php-fpm.log.2
    error: error opening /opt/alt/php-fpm56/usr/var/log/php-fpm.log.2: No such file or directory

It appears from the above that the logrotate action DOES execute BUT it throws the initial error, however, looking in the directory there are NO extra/new logs in the folder?

Any thoughts greatly appreciated


Offline
*
Re: Logrotate domlogs
« Reply #2 on: February 19, 2019, 11:23:28 PM »
I have since run the Run Now action from CWP again and it has renamed the log file to php-fpm.log.1 but still returns the error. Running it multiple times appears to do nothing.... running the logrotate command from shell gives me the unsurprising (the log file has been renamed by the Run Now action) following

reading config file /etc/logrotate.d/FPM56
error: /etc/logrotate.d/FPM56:1 lines must begin with a keyword or a filename (possibly in double quotes)
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /opt/alt/php-fpm56/usr/var/log/php-fpm.log  forced from command line (1 rotations)
empty log files are not rotated, old logs are removed
considering log /opt/alt/php-fpm56/usr/var/log/php-fpm.log
  log /opt/alt/php-fpm56/usr/var/log/php-fpm.log does not exist -- skipping

In the long/short term I'd like to be able to create logrotate conf files for all files in my domlogs folder that are getting quite large as well as the php-fpm.log files that are also increasing in size... I currently have 4 versions of PHP installed/being used
« Last Edit: February 19, 2019, 11:26:01 PM by cwpnz »

Offline
***
Re: Logrotate domlogs
« Reply #3 on: February 20, 2019, 03:03:52 AM »
The rotation needs make sense with file '/var/lib/logrotate/logrotate.status'
Did you already check that file..??
The 'weekly' token may be means that logrotate wants to see at least a week old entry for your access.log file in order to rotate it.
Hence the problem seems to be that you are not storing the state entry to trigger the rotation.
Try to invert the order of 'missingok' before rotate, and touch a old file mentioned in file ''/var/lib/logrotate/logrotate.status'.

Regards,
Netino

Offline
*
Re: Logrotate domlogs
« Reply #4 on: February 20, 2019, 04:23:59 AM »
Hey Netino, thanks for the reply

Have checked the logrotate.status file and this line is present

"/opt/alt/php-fpm56/usr/var/log/php-fpm.log" 2019-2-20-9:19:55

I'm assuming this means that the logration action for php-fpm56 has fired? After changing the order of the missingok directive and pressing the Run Now button in CWP, the log file has an extension of .1 so php-fpm.log.1 however, it still generates the following error

error: /etc/logrotate.d/FPM56:1 lines must begin with a keyword or a filename (possibly in double quotes)

Thanks for your assistance

Offline
*
Re: Logrotate domlogs
« Reply #5 on: February 21, 2019, 09:44:32 PM »
Created and left the job to run, received this

error: FPM56:1 lines must begin with a keyword or a filename (possibly in double quotes)
error: syslog:1 lines must begin with a keyword or a filename (possibly in double quotes)
error: syslog:12, unexpected text after }
logrotate_script: $'\r': command not found

any more thoughts that might assist with this setup, gratefully accepted

Offline
***
Re: Logrotate domlogs
« Reply #6 on: February 23, 2019, 03:15:09 AM »
Try to run logrotate in debug mode, with the following commands:
Code: [Select]
logrotate -d /etc/logrotate.d/FPM56
logrotate -d /etc/logrotate.d/syslog

According logrotate documentation, in debug mode, no changes will be made to the logs or to the logrotate state file.
And post here the results.

Offline
*
Re: Logrotate domlogs
« Reply #7 on: February 23, 2019, 03:33:54 AM »
Syslog returns the following in debug mode

reading config file /etc/logrotate.d/syslog
error: /etc/logrotate.d/syslog:1 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.d/syslog:12, unexpected text after }
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
 after 1 days (30 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/cron
  log does not need rotating (log has been rotated at 2019-2-23 3:49, that is not day ago yet)
considering log /var/log/maillog
  log does not need rotating (log has been rotated at 2019-2-23 3:49, that is not day ago yet)
considering log /var/log/messages
  log does not need rotating (log has been rotated at 2019-2-23 3:49, that is not day ago yet)
considering log /var/log/secure
  log does not need rotating (log has been rotated at 2019-2-23 3:49, that is not day ago yet)
considering log /var/log/spooler
  log does not need rotating (log is empty)not running postrotate script, since no logs were rotated

From FPM56 I get the following

reading config file /etc/logrotate.d/FPM56
error: /etc/logrotate.d/FPM56:1 lines must begin with a keyword or a filename (possibly in double quotes)
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /opt/alt/php-fpm56/usr/var/log/php-fpm.log  weekly (1 rotations)
empty log files are not rotated, old logs are removed
considering log /opt/alt/php-fpm56/usr/var/log/php-fpm.log
  log does not need rotating (log has been already rotated

If I run the logrotate command from the CWP interface for FPM56, it renames the log file with an .1 extension. Thanks for all your assistance

Offline
***
Re: Logrotate domlogs
« Reply #8 on: February 23, 2019, 04:09:48 AM »
It is executing correctly, but continues to claim about "double quotes" in the filename.

Is possible you have uploaded file from windows computer in "binary" format to the server..??
(if so, install a program named "dos2unix", and convert them)

If no, try to put filenamed in double quotes really.

Offline
*
Re: Logrotate domlogs
« Reply #9 on: February 23, 2019, 10:21:33 PM »
Hey Netino, I'd thought of that but then couldn't understand why the same error is appearing from the syslog rotate file? That one is a system default (I believe) and hasn't been changed by me. I also used the CWP interface to the Logrotate manager to create my custom job and typed the commands in manually. I will try the double quotes... when you say double quotes you mean of the entire file path, correct?

Offline
*
Re: Logrotate domlogs
« Reply #10 on: February 23, 2019, 10:26:55 PM »
Hey Netino, I'd thought of that but then couldn't understand why the same error is appearing from the syslog rotate file? That one is a system default (I believe) and hasn't been changed by me. I also used the CWP interface to the Logrotate manager to create my custom job and typed the commands in manually. I will try the double quotes... when you say double quotes you mean of the entire file path, correct?

Well, that is interesting... I have looked in the log file directory and found a NEW log file has been created and renamed php-fpm.log-20190224

Date/time stamp is 22/02/19 02:43

There is another log in the directory php-fpm.log with a time stamp of 24/02/19 03:14 so something is working/happening. I think I'll change the occurrence of log rotation to hourly to see if it is in fact generating new files

Offline
*
Re: Logrotate domlogs
« Reply #11 on: February 23, 2019, 10:38:23 PM »
I've created new CONF files and on saving in the CWP Logrotate editor receive the following error:

Notice: Undefined variable: file_size in /usr/local/cwpsrv/htdocs/resources/admin/modules/file_editor.php on line 0

The conf file entry is the following

"/opt/alt/php-fpm71/usr/var/log/php-fpm.log" {
weekly
create 0644 root root
rotate 3
size 50M
missingok
notifempty
}

If after saving the above I open it again for editing and save it (with NO changes) there is no error message returned, there is a success message..

Offline
***
Re: Logrotate domlogs
« Reply #12 on: February 24, 2019, 07:31:13 PM »
May be it interpreting the '-' character in path ("/opt/alt/php-fpm71/usr/var/log/php-fpm.log") as a needed to double quotee character.

Offline
*
Re: Logrotate domlogs
« Reply #13 on: February 24, 2019, 08:22:31 PM »
Decided to just go ahead and create the conf files and they appear to be working as expected - still not sure why the error is thrown but if it isn't interfering with the process..

Thanks for your time and input Netino

Offline
*
Re: Logrotate domlogs
« Reply #14 on: February 24, 2019, 08:23:48 PM »
tokar86a? I created the following conf file for my domlogs folder - hope it helps

"/usr/local/apache/domlogs/*" {
weekly
create 0644 root root
rotate 3
size 10M
dateext
missingok
notifempty
}