implementation of access.log with if condition

Lucas Rolff lucas at lucasrolff.com
Mon Jul 31 12:26:04 UTC 2017


> I don't want to locate logs on ssd main (hardrive /var/log/nginx/) which is obviously smaller hard disk than my external sata hdd (/externalhdd/log/nginx/

Setup log rotation depending on size of logs or daily rotation.

> I still want my website to operate after restart because every week server restart by itself due to some limitation of some programs

Instead of randomly restarting – do a config check and only restart if the config is valid (should also validate the log location)

You write in your initial post that if the access log exists, then you should use the external harddrive, however – have you considered that the file might exist but the device is in read-only?

You could modify your init script or systemd start script to actually check for these things and generate a new nginx config depending on the result (hint: use place holders).

You could also symlink /externalhdd/log/nginx to /var/log/nginx – in this case if the drive is mounted it would use the external drive, if it’s not mounted the file would get written to your SSD – but still won’t make up for a read only device in case that happens.

To be honest, log rotation or symlinks would IMO be the best options.

On 31/07/2017, 13.08, "nginx on behalf of lifeisjustabout" <nginx-bounces at nginx.org on behalf of nginx-forum at forum.nginx.org> wrote:

    Thanks for the response. The reason why I want to implement this is because
    I have dedicated server and thanks to nginx everything is work perfectly so
    I don't need to check server everyday. I don't want to locate logs on ssd
    main (hardrive /var/log/nginx/) which is obviously smaller hard disk than my
    external sata hdd (/externalhdd/log/nginx/). I am afraid if something
    happens to external hard drive time to time, I still want my website to
    operate after restart because every week server restart by itself due to
    some limitation of some programs. I guess it will give me error message
    nginx couldn't found access.log if external hard disk dies prior to restart
    nginx. I want to avoid this problem.
    
    thanks.
    
    Posted at Nginx Forum: https://forum.nginx.org/read.php?2,275761,275763#msg-275763
    
    _______________________________________________
    nginx mailing list
    nginx at nginx.org
    http://mailman.nginx.org/mailman/listinfo/nginx
    



More information about the nginx mailing list