ACCT(2)
π ACCT(2) β the acct system call, section 2 of the System Calls Manual π
okay bestie so we're doing acct today and honestly? it's giving accountant energy but in a cool way. system calls manual, section 2, let's go π«Ά
β¨ NAME β¨
acct β enable or disable process accounting
like, it turns the bean-counting on and off. that's the whole vibe. π
π LIBRARY π
Standard C Library (libc, -lc)
yep, plain old libc, no fancy extra library needed, we love a low-maintenance icon πΈ
π SYNOPSIS π
#include <unistd.h>
int
acct(const char *file);
look at her. one argument. one int return. no drama. π
π¦ DESCRIPTION π¦
so the acct() system call enables or disables the collection of system accounting records. literally what it says on the tin, no cap.
if the argument file is a null pointer, accounting is disabled. done, off, goodnight. π΄
if file is an existing pathname (null-terminated, obvi), record collection is enabled and β here's the part you gotta know β for every process initiated which terminates under normal conditions, an accounting record gets appended to file. every single one. she's thorough. π
now, "abnormal conditions of termination"? that's reboots or other fatal system problems. so if the box just dies, no receipt, sorry bestie. π
and heads up: records for processes which never terminate cannot be produced by acct(). if it never ends, there's nothing to write. it's giving forever-loop energy, and honestly? not our problem. π
for more info on the record structure used by acct(), go peek at <sys/acct.h> and acct(5). the lore is all there, iykyk π
also important: this call is permitted only to the super-user. root only, babes. the rest of us are just watching. π
β NOTES β
okay this part is lowkey the best part because she's got β¨self-preservationβ¨:
Accounting is automatically disabled when the file system the accounting file resides on runs out of space β and it's enabled when space once again becomes available. like she just quietly pauses when the disk is full and picks back up when there's room. main character behaviour, truly. π
the values controlling this behaviour can be modified using the following sysctl(8) variables:
kern.acct_chkfreqβ Specifies the frequency (in seconds) with which free disk space should be checked. basically how often she looks at the disk like "u good?" πkern.acct_resumeβ The percentage of free disk space above which process accounting will resume. cross this line and we're back, baby πkern.acct_suspendβ The percentage of free disk space below which process accounting will suspend. dip under this and she's napping π΄
π RETURN VALUES π
on error, -1 is returned. periodt.
The file must exist and the call may be exercised only by the super-user. so: file exists β
, root β
, or you get the -1. π
π ERRORS π
The acct() system call will fail if one of the following is true:
[EPERM]β The caller is not the super-user. sorry bestie, you're not on the list π«[ENOTDIR]β A component of the path prefix is not a directory. that's not a folder, that's... something else π«[ENAMETOOLONG]β A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. girl, the name is TOO LONG π[ENOENT]β The named file does not exist. it's not there. nowhere. vanished. π[EACCES]β Search permission is denied for a component of the path prefix, or the path name is not a regular file. no entry for you β[ELOOP]β Too many symbolic links were encountered in translating the pathname. the symlinks are linking in circles, iconic but illegal π[EROFS]β The named file resides on a read-only file system. can't write to a read-only disk, that's just facts π[EFAULT]β Thefileargument points outside the process's allocated address space. that pointer is out of bounds, bestie, put it down π«£[EIO]β An I/O error occurred while reading from or writing to the file system. the disk is having a moment π΅[EINTEGRITY]β Corrupted data was detected while reading from the file system. the data is not okay. corrupted. bad vibes. π₯
π SEE ALSO π
go read those next, they're the supporting cast and they ate π
π HISTORY π
The acct() function appeared in Version 7 AT&T UNIX. an elder. a legend. a pioneer. we respect the OGs π
and that's the whole page, bestie β from Debian, dated March 30, 2020, ACCT(2), signing off π thanks for reading my little manpage essay, go enable some accounting (as root!!) and slay β¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms