3 ms·
Remembered to add the `2>&1` stderr>stdout output redirection: ps wxa | grep <cmd> # or pgrep strace -f -f -e trace=file <cmd> 2>&1 | grep -v '-1 ENOENT (
by westurner 3y ago
Remembered to add the `2>&1` stderr>stdout output redirection:
ps wxa | grep <cmd> # or pgrep
strace -f -f -e trace=file <cmd> 2>&1 | grep -v '-1 ENOENT (No such file or directory)$'
Bash manual > 3. Basic Shell Features > 3.6 Redirections: https://www.gnu.org/software/bash/manual/html_node/Redirections.html https://www.gnu.org/software/bash/manual/html_node/Redirecti...
In lieu of strace, IDK how fast `ls -al /proc/${pid}/fd/*` can be polled and logged in search of which config file it is; almost like `lsof -n`:
pid=$$ # this $SHELL's pid
help set; # help help
(set -B; cat /proc/"${pid}"/{cmdline,environ}) \
| tr '\0' $'\n'
(while 1; do echo \#$pid; ls -al /proc/${pid}/fd/*; done) | tee "file_handle_to_file_path.${pid}.log"
# Ctrl-C
It's good Configuration Management practice to wrap managed config with a preamble/postamble indicating at least that some code somewhere wrote that and may overwrite whatever a user might manually change it to (prior to the configuration management system copying over or re-templating the config file content, thus overwriting any manual modifications)
## < managed by config_mgmt_system_xyz (in path.to.module.callable) >
## </ managed>
- hawski 3y agoI prefer to use process substitution (not in POSIX): strace -f -e trace=file -o >(grep -v ENOENT) <cmd>