blunt_blade
New Around Here
Just a heads up for anyone trying to setup logrotate as per the instructions in posts #16 and #18.
As per this post here: http://www.snbforums.com/threads/entware-logrotate-w-o-user-root.15384/ there are a number of changes that need to be made in order to get this working properly.
Firstly to test your setup you can run
to do a dry test run after following the instructions in the above mentioned posts (#16 and #18), this will more than likely throw an error regarding no password being present in the file etc, this is what the link above addresses.
Briefly here is what I found needed to be done in order to get this working correctly on my router:
As per this post here: http://www.snbforums.com/threads/entware-logrotate-w-o-user-root.15384/ there are a number of changes that need to be made in order to get this working properly.
Firstly to test your setup you can run
Code:
/opt/sbin/logrotate -d /opt/etc/logrotate.conf
Briefly here is what I found needed to be done in order to get this working correctly on my router:
- Create a root user with the name "root" by adding the relevant entries into the /jffs/configs/passwd.add and /jffs/configs/shadow.add files
- Add an su entry into the syslog.log portion of the logrotate.conf file so that it will run as your user (not the root user created in step 1 above), assuming your user name is "admin" it should look something like this:
Code:/opt/var/log/syslog.log { su admin root size 1024k weekly rotate 9 postrotate killall -HUP syslogd endscript }
- Remove the user name from the cronjob entry, so instead of
Code:
0 0 * * * admin /opt/sbin/logrotate -f /opt/etc/logrotate.conf &>/dev/null
Code:0 0 * * * /opt/sbin/logrotate -f /opt/etc/logrotate.conf &>/dev/null
- Remove the -f flag from the cron job as this forces logrotate to rotate the logs everytime it runs, as opposed to only rotating them weekly or however you've setup your config. So the cron job should rather look like this then:
Code:
0 0 * * * /opt/sbin/logrotate /opt/etc/logrotate.conf &>/dev/null
- With the current config as it is in post #16 it has both size and weekly entries for the syslog.log configuration. With it setup this way logrotate will ignore the weekly instruction and will only rotate the log when it reaches 1024k in size. I've changed this to rather use the maxsize option as opposed to size, in conjunction with the weekly option, which will then rotate the log weekly or when it reaches 1024k, whichever comes first. So my entry for syslog.log then looks like this:
Code:/opt/var/log/syslog.log { su admin root maxsize 1024k weekly rotate 9 postrotate killall -HUP syslogd endscript }
Last edited: