Real time plot of the evolution of the number of files with gnuplot

Usage example to monitor the number of files dms/smap_*_no_H.dms

$ ./file_monitor.sh dms/smap_\*_no_H.dms

The main script: file_monitor.sh

#!/bin/bash
# -*- coding: UTF8 -*-
infile="$1"
outfile=/dev/shm/nfiles.txt
t_0=$(date +"%s")
for i in $(seq 1 10)
do
t=$(date +"%s")
delta_t=$(($t-$t_0))
nfiles=$(echo $infile | wc -w)
echo $delta_t $nfiles >> $outfile
sleep 2
done
gnuplot loop.plt &
echo "$infile"
while true
    do
        t=$(date +"%s")
        delta_t=$(($t-$t_0))
        nfiles=$(echo $infile | wc -w)
        echo $delta_t $nfiles >> $outfile
        trap "echo Exited!; break" SIGINT
        sleep 2
    done
/bin/rm $outfile

The gnuplot script: loop.plt

set grid
set xlabel "running time (s)"
#fitline(x) = a*x + b
#fit fitline(x) '/dev/shm/nfiles.txt' using 1:2 via a, b
plot '/dev/shm/nfiles.txt' using 1:2 with linespoints#, fitline(x)
pause 2
replot
reread

To monitor the number of qsub jobs: qstat_monitor.sh

#!/bin/bash
# -*- coding: UTF8 -*-
outfile=/dev/shm/nfiles.txt
t_0=$(date +"%s")
for i in $(seq 1 2)
do
t=$(date +"%s")
delta_t=$(($t-$t_0))
nfiles=$(qstat -u $USER | grep $USER | wc -l)
echo $delta_t $nfiles >> $outfile
sleep 20
done
gnuplot loop.plt &
while true
    do
        t=$(date +"%s")
        delta_t=$(($t-$t_0))
        nfiles=$(qstat -u $USER | grep $USER | wc -l)
        echo $delta_t $nfiles >> $outfile
        trap "echo Exited!; break" SIGINT
        sleep 20
    done
/bin/rm $outfile
If you want to ask me a question or leave me a message add @bougui505 in your comment.