acct(2)
๐ acct(2) โ the process accounting switch ๐
okay bestie, so this is a page from the System Calls Manual (yes, section 2, we're in kernel-land, it's giving syscall energy โจ) and honestly? it's such a lil guy with such big power. let's get into it ๐ซถ
๐ธ NAME ๐ธ
acct โ switch process accounting on or off
like... a literal on/off switch for the receipt-printer of your system. bestie is a toggler ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
so you already have it, no extra install, no extra drama ๐
โจ SYNOPSIS โจ
#include <unistd.h>
int acct(const char *_Nullable path);
๐ฆ Feature Test Macro Requirements for glibc ๐ฆ
(peep feature_test_macros(7) if you need the lore, iykyk)
acct():
- Since glibc 2.21:
_DEFAULT_SOURCE
- In glibc 2.19 and 2.20:
_DEFAULT_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
- Up to and including glibc 2.19:
_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
so basically, depending on which glibc era you're living in, you gotta define the right macro or this thing ghosts you ๐ญ define responsibly!
๐ DESCRIPTION ๐
The acct() system call enables or disables process accounting. periodt.
Here's the tea โ โ pass it the pathname of an existing file as its argument and accounting gets turned on, and then records for every single terminating process get appended to that file as each one terminates. like a lil diary where every process writes its final entry before it exits. so sentimental honestly ๐ฅน
And if you pass NULL as the argument? accounting gets turned off. that's it, that's the whole switch. iconic behaviour, no notes ๐
๐ฅ RETURN VALUE ๐ฅ
- On success: zero is returned. slay. โ
- On error:
-1is returned, anderrnois set to tell you what went wrong. rude but informative ๐
๐ญ ERRORS ๐ญ
okay so this is the part where things can go sideways. every one of these is a real mood, let's go through them:
EACCESโ Write permission is denied for the specified file, or search permission is denied for one of the directories in the path prefix of path (peeppath_resolution(7)for that whole saga), or path is not a regular file.EFAULTโ path points outside your accessible address space. bestie is pointing at โจthe voidโจ outside your memory.EIOโ Error writing to the file path. the write just... didn't write.EISDIRโ path is a directory. bestie, that's a folder, not a file, that's not it ๐ELOOPโ Too many symbolic links were encountered in resolving path. symlink rabbit hole, we've all been there ๐ณ๏ธENAMETOOLONGโ path was too long. it's giving novel, not pathname ๐ENFILEโ The system-wide limit on the total number of open files has been reached. the whole system ran out of file slots, not just you.ENOENTโ The specified path does not exist. it's not real, it was never real ๐ENOMEMโ Out of memory. no thoughts, head empty, RAM empty.ENOSYSโ BSD process accounting has not been enabled when the operating system kernel was compiled. the kernel config parameter that controls this feature isCONFIG_BSD_PROCESS_ACCT. so if your kernel wasn't built with it, this syscall is lowkey just a rumour ๐ซ๏ธENOTDIRโ A component used as a directory in path is not in fact a directory. it was pretending. fraud alert ๐จEPERMโ The calling process has insufficient privilege to enable process accounting. on Linux, theCAP_SYS_PACCTcapability is required. so no cap (capability), noCAP_SYS_PACCT๐EROFSโ path refers to a file on a read-only filesystem. you cannot write to the read-only, that's literally the whole point ๐งEUSERSโ There are no more free file structures or we ran out of memory. two-for-one chaos.
fr fr read these, don't just skim.EPERMis the one that gets people โ if you don't haveCAP_SYS_PACCT, it's over before it started ๐
๐ STANDARDS ๐
None. nope, not standardized, no committee signing off on this one, it's just out here living its life ๐
โญ HISTORY โญ
- SVr4
- 4.3BSD
vintage! a classic! we stan an elder ๐
๐ NOTES ๐
- No accounting is produced for programs running when a system crash occurs. and in particular, nonterminating processes are never accounted for. so if a process never ends, it never gets a diary entry. it simply persists. main character energy, honestly, refusing to have an exit ๐
- The structure of the records written to the accounting file is described in
acct(5). go peep that page for the record layout lore ๐
๐ซ SEE ALSO ๐ซ
okay bestie that's the whole page!! you now know how to flip process accounting on and off, every reason it might scream at you, and the fact that crashed systems just lose the receipts ๐ญ go forth and toggle responsibly ๐ซถโจ
this lil rewrite was brought to you by Linux man-pages 6.20, dated 2025-05-17 โ mwah, love u, bye ๐๐๐ฆ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms