Something Odd - "top" Delivers Nada When Run By Crontab
c186282 <[email protected]>
| Newsgroups | comp.os.linux.misc |
|---|---|
| Organization | wokiesux |
| Message-ID | <[email protected]> |
Wrote a short Python script that uses os.system() to
run 'top' ... redirecting the output to a file. We
then clean-up the weird chars in the file and append
it to an ongoing log file.
Run the script from the CL and it works perfectly.
Run it via root crontab though and the top redirect
file exists, but is EMPTY.
Tried it as an every-five-minutes thing direct from
root crontab. Re-did the script a bit to make it
into a daemon run as an @reboot from root crontab.
Both approaches, EMPTY results file. The '>' sort
of works, but nothing shows up IN it.
The line :
os.system("top -n 1 > topp.txt")
We then clean up weird chars and append it
to the real log file. DID check if there was
any output BEFORE the clean-ups. Nada.
I've tried firming up the path - but I do
an os.chdir() anyway using sys.argv[0] at
the top of the script anyhow. Regardless,
the 'top' output delivers NOTHING to the
dest file. DOES create it, but ...
So ... why doesn't this work ???
'top' is 'ubiquitous', nothing new there.
The different behavior from the CL vs crontab
is puzzling. Been screwing with this all day,
trying lots of little variants.
The unit crashes every so often, so I figured I'd
make a log of 'top' data to see if it was starting
to use lots more mem/cpu somewhere.
Target = Pi3 + PiOS (Deb)