I have installed slurm command to track the amount of data consumed by an interface apt install slurm
My gold is to save its output into a file, I wrote this script to let me do that, but I did not get the expected results.
#!/bin/bash
echo "#####################################"
date "+%F %H:%M:%S :: snapshot on interface"
timeout 5s slurm -s -i eno1 >> /home/trackeNIC.log;
I add this job for running the script
* * * * * bash /home/trackeNIC.sh >> /home/trackeNIC.log
The result I got is :
#####################################
2020-05-15 15:02:01 :: snapshot on interface
#####################################
2020-05-15 15:03:01 :: snapshot on interface
#####################################
I expect something like :
#####################################
2020-05-15 15:02:01 :: snapshot on interface
-= slurm 0.4.3 =-
x
x
x
x x
xxxx
xxxx
xx x
x x
x
x
Active Interface: eno1 Interface Speed: unknown
Current RX Speed: 141.12 KB/s Current TX Speed: 17.63 KB/s
Graph Top RX Speed: 876.31 KB/s Graph Top TX Speed: 32.47 KB/s
Overall Top RX Speed: 876.31 KB/s Overall Top TX Speed: 32.47 KB/s
Received Packets: 24045657 Transmitted Packets: 14187466
GBytes Received: 21.377 GB GBytes Transmitted: 1.381 GB
Errors on Receiving: 0 Errors on Transmission: 0
#####################################
2020-05-15 15:03:01 :: snapshot on interface
-= slurm 0.4.3 =-
x
x
x
x x
xxxx
xxxx
xx x
x x
x
x
Active Interface: eno1 Interface Speed: unknown
Current RX Speed: 141.12 KB/s Current TX Speed: 17.63 KB/s
Graph Top RX Speed: 876.31 KB/s Graph Top TX Speed: 32.47 KB/s
Overall Top RX Speed: 876.31 KB/s Overall Top TX Speed: 32.47 KB/s
Received Packets: 24045657 Transmitted Packets: 14187466
GBytes Received: 26.377 GB GBytes Transmitted: 2.381 GB
Errors on Receiving: 0 Errors on Transmission: 0
#####################################
Any help would be appreciated.
slurm
with the full path to theslurm
executable? ThePATH
variable may well be different in the environment that cron jobs are executed compared to your interactive shell environment.timeout 5s slurm -s -i eno1 >> /home/trackeNIC.log;
does not append the output into the file.timeout
andslurm
withcommand -v timeout
andcommand -v slurm
in an interactive shell. Then use those paths when you call those tools in your script. Does that make it work?