Tag: cron

bash ansi codes to html for html reports from shell script

How many times you have felt that there was some simple way to convert bash ansi escape sequences ( colors as well in terminal ) to html equivalent so that you can send the same as html report in email. Here is simple solution. One way is to use ccze if you are using this for logs – colorize your logs and for more generic solution.


dnf install python3-ansi2html.noarch

after this is installed, you can use something like this:

/usr/bin/python3-ansi2html -l -f 12 -i

You can see the help for ansi2html to see what parameters mean and which ones suit you best 🙂

Trello – backup to your linux machine

Just in case, you are looking for backing up your trello account boards, you can use the following bash script to do so:


#!/bin/bash -
#          FILE: backup-trello.sh
#         USAGE: ./backup-trello.sh
#       OPTIONS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
# Last modified: Thu Dec 22, 2016  01:14PM
#       CREATED: 08/12/2016 09:41:08 AM IST
#      REVISION: $Revision: 1.0 $$

# Your backup directory

# Your trello api token and key goes here 🙂

# IDs of the boards go here. This is easy to get, just go to your 
# board and check the last part of URL
BOARDS=( a b )


for i in ${BOARDS[*]}
    /usr/bin/curl -H 'Accept-Encoding:gzip, deflate, br' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' "$URL$i.json?&key=$key&token=$token$POST" > "$BDIR/$i.json.gz"
    # gzip -f "$BDIR/$i.json"


You can add this script in cron, if you wish to do so 🙂

Oh, and BTW the script gets the details in zipped format so output is created as <id of board>.json.gz.

script to get hard disk health in fedora/ubuntu

First, put this in a script.


#Change as appropriate

export sub="SmartCtl data for HDD"
echo 'To: <Your Email>
Sub: [Cron] $sub
MIME-Version: 1.0
Content-Type: text/html
Content-Disposition: inline


echo '<style>

hr {
    display: block;
    height: 1px;
    border: 0;
    border-top: 1px solid #ccc;
    margin: 1em 0;
    padding: 0;

echo '<h2>Errors on HDD:</h2>'
echo '<hr>'
sudo smartctl -l error  /dev/$HDD
echo '<h2>Health of HDD:</h2>'
echo '<hr>'
sudo smartctl -H  /dev/$HDD

echo '<h2>Detailed info</h2>'
echo '<hr>'
sudo smartctl -a -d ata /dev/$HDD

echo '<h2>Journalctl output for smartd</h2>'
echo '<hr>'

if [[ -f /etc/fedora-release ]]
journalctl -x --show-cursor -u smartd --since=yesterday
#This is for Ubuntu.. still using dmesg

dmesg -T -l err,crit,alert,emerg


echo '<h2>All Details</h2>'
echo '<hr>'

sudo smartctl --xall /dev/$HDD

echo "Thanks for using Amit Agarwal's script"
echo '</pre></html>'

and then put this in cron:

30 15 * * 5 <script name> |/usr/sbin/sendmail -t

You need to have mail configured to receive the mails.