I have checked this question regarding crontab failures.
I am running this command to capture the htop
command and create a snapshot of it in html format (htop output to human readable file):
/bin/echo q | /usr/bin/htop | /usr/bin/aha --black --line-fix > /tmp/htop.html
This command works correctly on terminal and it doesn't depend on any environment variables. When I add this command as a cronjob, it just generates an empty html file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- This file was created with the aha Ansi HTML Adapter. http://ziz.delphigl.com/tool_aha.php -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml; charset=UTF-8" />
<title>stdin</title>
</head>
<body style="color:white; background-color:black">
<pre>
</pre>
</body>
</html>
Any reason why it is not able to capture the output via cron
?
env -i htop
trick to clean up the environment. – PerlDuck Jun 08 '18 at 10:39