Home / How to set file permissions at /var/log/sa to be 640 permanently

How to set file permissions at /var/log/sa to be 640 permanently

Here is the permanent solution. We change umask value of the “sar” logs when it is created by sysstat to change the file permissions at /var/log/sa to be 640. But after updating packages, the umask value reverted to 0022.

The executables sa1 and sa2 are called by sysstat-collect.service and sysstat-summary.service. So first, copy these unit files to under /etc/systemd/system/ directory, and modify the copied files, which would override the above files under /usr directory.

 # cp /usr/lib/systemd/system/sysstat-summary.service /etc/systemd/system/ 
# cp /usr/lib/systemd/system/sysstat-collect.service /etc/systemd/system/

These files each have a below Execstart line pointing to the executable.

ExecStart=/usr/lib64/sa/sa2 -A
ExecStart=/usr/lib64/sa/sa1 1 1

Instead of directly modifying umask value in these files, make a copy of these, for example;

 # cp /usr/lib64/sa/sa2 /usr/local/bin/
# cp /usr/lib64/sa/sa1 /usr/local/bin/

Then change the umask value in the copied files.

 # vim /usr/local/bin/sa2
# vim /usr/local/bin/sa1

Next, modify Execstart lines of the copied unit files.

# vim /etc/systemd/system/sysstat-summary.service 
~~ snip ~~
ExecStart=/usr/local/bin/sa2 -A
~~ snip ~~

Lastly, make sure to load the modified unit files.

 # systemctl daemon-reload

The main reason for this issue is that when the sysstat package is updated, any changes made to /usr/lib64/sa/sa1 and /usr/lib64/sa/sa2 are lost.

Leave a Reply