I just created a script to output htop
automatically every n minutes using this method → https://askubuntu.com/a/726661/253251, I put the script on crontab so it can be executed daily. But the output produced by cron was incomplete.
However, if I execute the command manually, there will be no truncated text.
Is there any settings that I can tweak to achieve full output in cron?
UPDATE
I have already tried Waltinator suggestion, it doesn't work and it stretch the output so long which is not what I want.
How to make output similar to the one executed manually ?
It seems to me that you just have to pick the "right" value for
COLUMNS
. In a way, your manual method did that as well since you widened the window to some suitable value before you ranhtop
.I don't think there is a "magical way" to do it, unless you ran
ps
or some similar command, find out the length of the longest command being run, and then set that to the value ofCOLUMNS
(plus some more columns for everything that appears to the left of it), and then runhtop
.I guess this could be achieved with this code:
Credit for this goes to these two pages: 1 and 2, which I just copied from.
The part on the left isn't variable in length, so you can add it on as a constant. Then have your script set
COLUMNS
using this value. I'm not sure if this will work... Good luck!