How to stop pacct daemon/service and stop its loggging in Linux ?
Today in this post, we will look at an interesting article how to stop the pacct service in Linux.
1. Verify if pacct service is disabled on system.
### The default everyone uses to check services is to use "pf -ef" command. ### However it will not be visible here as this is process accounting not a separate process. [root@ngelinux001 ~]# ps -ef | grep -i acct root 83785 83688 0 22:59 pts/287 00:00:00 grep -i acctas ### Better to check chkconfig and make sure its off everywhere. [root@ngelinux001 ~]# chkconfig --list | grep -i acct psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@ngelinux001 ~]#
2. Check out the binary and log path path of the service.
[saketj@ngelinux001 ~]$ cat /etc/logrotate.d/psacct # Logrotate file for psacct RPM /var/account/pacct { #prerotate loses accounting records, let's no # prerotate # /usr/sbin/accton # endscript compress #delaycompress notifempty daily rotate 3 #rotate 31 create 0600 root root postrotate /usr/sbin/accton /var/account/pacct endscript } [saketj@ngelinux001 ~]$ file /usr/sbin/accton /usr/sbin/accton: symbolic link to `../../sbin/accton'
3. Check if the process is running on not.
To check this, we need to check last modificaiton time of the log file.
If its not updating now, means its stopped.
[root@ngelinux001 ~]# ls -l /var/account/pacct -rw------- 1 root root 43410624 May 29 23:02 /var/account/pacct [root@ngelinux001 ~]# date Sun May 29 23:02:33 PDT 2022
4. The process seems running as of now.
Stop the process accounting daemon.
[root@ngelinux001 ~]# /usr/sbin/accton #### Running command without any argument just stops it on the server.
5. Check the size after some time, if it remains same now, it means the daemon is stopped.
[root@ngelinux001 ~]# ls -l /var/account/pacct -rw------- 1 root root 43417408 May 29 23:03 /var/account/pacct [root@ngelinux001 ~]# date Sun May 29 23:03:16 PDT 2022 root@ngelinux001 ~]# date Sun May 29 23:05:42 PDT 2022 [root@ngelinux001 ~]# ls -l /var/account/pacct -rw------- 1 root root 43417408 May 29 23:03 /var/account/pacct [root@ngelinux001 ~]# Since now the size is same and is not increasing, it means the daemon is stopped.