Closed cgaugel closed 1 year ago
The nvme_metrics.sh script does not write to my log file. The file is empty. Other scripts are working - what am I missing?
My file is located in /root/nvme_metrics.sh:
-rwxr-xr-x 1 root root 3700 Mar 7 11:26 nvme_metrics.sh
My Crontab:
* * * * * /bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom
My target file:
-rw-r--r-- 1 root root 0 Mar 7 11:54 /var/lib/node_exporter/textfile_collector/disk_health.prom
The syslog when the cronjob was executed:
Mar 7 11:55:01 ebay CRON[807]: (root) CMD (/bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom)
Ii also tried the following crontabs:
* * * * * /bin/bash /root/nvme_metrics.sh | sponge /var/lib/node_exporter/textfile_collector/disk_health.prom * * * * * /bin/bash /root/nvme_metrics.sh | tee /var/lib/node_exporter/textfile_collector/disk_health.prom
* * * * * /bin/bash /root/nvme_metrics.sh | sponge /var/lib/node_exporter/textfile_collector/disk_health.prom
* * * * * /bin/bash /root/nvme_metrics.sh | tee /var/lib/node_exporter/textfile_collector/disk_health.prom
Anyone else facing the same problem? I am running Debian 10:
Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster
I found it. I had to change the nvme command in the shell script to use the absolute path like
/usr/sbin/nvme list -o json instead of nvme list -o json
/usr/sbin/nvme list -o json
nvme list -o json
Another way is to modify PATH for your cron job.
PATH
The nvme_metrics.sh script does not write to my log file. The file is empty. Other scripts are working - what am I missing?
My file is located in /root/nvme_metrics.sh:
-rwxr-xr-x 1 root root 3700 Mar 7 11:26 nvme_metrics.sh
My Crontab:
* * * * * /bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom
My target file:
-rw-r--r-- 1 root root 0 Mar 7 11:54 /var/lib/node_exporter/textfile_collector/disk_health.prom
The syslog when the cronjob was executed:
Mar 7 11:55:01 ebay CRON[807]: (root) CMD (/bin/bash /root/nvme_metrics.sh > /var/lib/node_exporter/textfile_collector/disk_health.prom)
Ii also tried the following crontabs:
* * * * * /bin/bash /root/nvme_metrics.sh | sponge /var/lib/node_exporter/textfile_collector/disk_health.prom
* * * * * /bin/bash /root/nvme_metrics.sh | tee /var/lib/node_exporter/textfile_collector/disk_health.prom
Anyone else facing the same problem? I am running Debian 10:
Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster