htop and crontab
up vote
0
down vote
favorite
I have a crontab like this for root user:
9 17 * * * TERM=xterm /bin/bash /root/htop_stat.sh
htop_stat.sh:
/usr/bin/echo q | /usr/bin/htop -C | /usr/bin/aha --line-fix | /usr/bin/html2text -width 999 | /usr/bin/grep --line-buffered -v "F1Help|xml version=" > /tmp/htop.txt
If I manually run htop_stat.sh as root, it works fine.
However, when the above cronjob kicks in, htop.txt only has the first 23 lines of htop's output.
Any idea?
terminal cron xterm htop
|
show 1 more comment
up vote
0
down vote
favorite
I have a crontab like this for root user:
9 17 * * * TERM=xterm /bin/bash /root/htop_stat.sh
htop_stat.sh:
/usr/bin/echo q | /usr/bin/htop -C | /usr/bin/aha --line-fix | /usr/bin/html2text -width 999 | /usr/bin/grep --line-buffered -v "F1Help|xml version=" > /tmp/htop.txt
If I manually run htop_stat.sh as root, it works fine.
However, when the above cronjob kicks in, htop.txt only has the first 23 lines of htop's output.
Any idea?
terminal cron xterm htop
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Yes, I actually started without and it would make/tmp/htop.txtempty becausehtoprelies on the environment variableTERM. Thanks.
– HCSF
Nov 20 at 10:15
Have you consider usingtop,ps?htopby definition is "interactive process viewer"
– Romeo Ninov
Nov 20 at 10:19
htopgives me a bit more detail about all the processes. That's why I choosehtopinstead. And yes,htopis interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.
– HCSF
Nov 20 at 10:23
It work fine because when you open terminal you haveTERMvariable set. Which is not the case with cron. In your shell script exec something like:stty rows 50 cols 132before the command and check the result
– Romeo Ninov
Nov 20 at 10:33
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a crontab like this for root user:
9 17 * * * TERM=xterm /bin/bash /root/htop_stat.sh
htop_stat.sh:
/usr/bin/echo q | /usr/bin/htop -C | /usr/bin/aha --line-fix | /usr/bin/html2text -width 999 | /usr/bin/grep --line-buffered -v "F1Help|xml version=" > /tmp/htop.txt
If I manually run htop_stat.sh as root, it works fine.
However, when the above cronjob kicks in, htop.txt only has the first 23 lines of htop's output.
Any idea?
terminal cron xterm htop
I have a crontab like this for root user:
9 17 * * * TERM=xterm /bin/bash /root/htop_stat.sh
htop_stat.sh:
/usr/bin/echo q | /usr/bin/htop -C | /usr/bin/aha --line-fix | /usr/bin/html2text -width 999 | /usr/bin/grep --line-buffered -v "F1Help|xml version=" > /tmp/htop.txt
If I manually run htop_stat.sh as root, it works fine.
However, when the above cronjob kicks in, htop.txt only has the first 23 lines of htop's output.
Any idea?
terminal cron xterm htop
terminal cron xterm htop
asked Nov 20 at 9:57
HCSF
256
256
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Yes, I actually started without and it would make/tmp/htop.txtempty becausehtoprelies on the environment variableTERM. Thanks.
– HCSF
Nov 20 at 10:15
Have you consider usingtop,ps?htopby definition is "interactive process viewer"
– Romeo Ninov
Nov 20 at 10:19
htopgives me a bit more detail about all the processes. That's why I choosehtopinstead. And yes,htopis interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.
– HCSF
Nov 20 at 10:23
It work fine because when you open terminal you haveTERMvariable set. Which is not the case with cron. In your shell script exec something like:stty rows 50 cols 132before the command and check the result
– Romeo Ninov
Nov 20 at 10:33
|
show 1 more comment
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Yes, I actually started without and it would make/tmp/htop.txtempty becausehtoprelies on the environment variableTERM. Thanks.
– HCSF
Nov 20 at 10:15
Have you consider usingtop,ps?htopby definition is "interactive process viewer"
– Romeo Ninov
Nov 20 at 10:19
htopgives me a bit more detail about all the processes. That's why I choosehtopinstead. And yes,htopis interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.
– HCSF
Nov 20 at 10:23
It work fine because when you open terminal you haveTERMvariable set. Which is not the case with cron. In your shell script exec something like:stty rows 50 cols 132before the command and check the result
– Romeo Ninov
Nov 20 at 10:33
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Yes, I actually started without and it would make
/tmp/htop.txt empty because htop relies on the environment variable TERM. Thanks.– HCSF
Nov 20 at 10:15
Yes, I actually started without and it would make
/tmp/htop.txt empty because htop relies on the environment variable TERM. Thanks.– HCSF
Nov 20 at 10:15
Have you consider using
top, ps? htop by definition is "interactive process viewer"– Romeo Ninov
Nov 20 at 10:19
Have you consider using
top, ps? htop by definition is "interactive process viewer"– Romeo Ninov
Nov 20 at 10:19
htop gives me a bit more detail about all the processes. That's why I choose htop instead. And yes, htop is interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.– HCSF
Nov 20 at 10:23
htop gives me a bit more detail about all the processes. That's why I choose htop instead. And yes, htop is interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.– HCSF
Nov 20 at 10:23
It work fine because when you open terminal you have
TERM variable set. Which is not the case with cron. In your shell script exec something like: stty rows 50 cols 132 before the command and check the result– Romeo Ninov
Nov 20 at 10:33
It work fine because when you open terminal you have
TERM variable set. Which is not the case with cron. In your shell script exec something like: stty rows 50 cols 132 before the command and check the result– Romeo Ninov
Nov 20 at 10:33
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
1
down vote
The prefix TERM=xterm is not allowed for a cron command, it is not a shell prompt.
Either put it as a separate line in the crontab file:
TERM=xterm
9 17 * * * /bin/bash /root/htop_stat.sh
or include it in your htop_stat.sh.
See man 5 crontab for details.
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The prefix TERM=xterm is not allowed for a cron command, it is not a shell prompt.
Either put it as a separate line in the crontab file:
TERM=xterm
9 17 * * * /bin/bash /root/htop_stat.sh
or include it in your htop_stat.sh.
See man 5 crontab for details.
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
add a comment |
up vote
1
down vote
The prefix TERM=xterm is not allowed for a cron command, it is not a shell prompt.
Either put it as a separate line in the crontab file:
TERM=xterm
9 17 * * * /bin/bash /root/htop_stat.sh
or include it in your htop_stat.sh.
See man 5 crontab for details.
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
add a comment |
up vote
1
down vote
up vote
1
down vote
The prefix TERM=xterm is not allowed for a cron command, it is not a shell prompt.
Either put it as a separate line in the crontab file:
TERM=xterm
9 17 * * * /bin/bash /root/htop_stat.sh
or include it in your htop_stat.sh.
See man 5 crontab for details.
The prefix TERM=xterm is not allowed for a cron command, it is not a shell prompt.
Either put it as a separate line in the crontab file:
TERM=xterm
9 17 * * * /bin/bash /root/htop_stat.sh
or include it in your htop_stat.sh.
See man 5 crontab for details.
answered Nov 20 at 10:35
nst0022
2412
2412
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
add a comment |
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
Thanks! You are indeed right that environment variable should be in a separate line per manpage. Tho, it is weird that putting in a separate line also has the same result as putting it in the same line preceding to the command.
– HCSF
Nov 20 at 14:27
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
I think why environment variable can be set preceding my script. link
– HCSF
Nov 21 at 1:46
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482923%2fhtop-and-crontab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you try to remove set of TERM in cron?
– Romeo Ninov
Nov 20 at 10:10
Yes, I actually started without and it would make
/tmp/htop.txtempty becausehtoprelies on the environment variableTERM. Thanks.– HCSF
Nov 20 at 10:15
Have you consider using
top,ps?htopby definition is "interactive process viewer"– Romeo Ninov
Nov 20 at 10:19
htopgives me a bit more detail about all the processes. That's why I choosehtopinstead. And yes,htopis interactive. But what I don't get is, "bash htop_stat.sh > /tmp/htop.txt" works perfectly.– HCSF
Nov 20 at 10:23
It work fine because when you open terminal you have
TERMvariable set. Which is not the case with cron. In your shell script exec something like:stty rows 50 cols 132before the command and check the result– Romeo Ninov
Nov 20 at 10:33