smartctl not executed in cron @reboot

mattlach

Member
Mar 23, 2016
154
12
18
Boston, MA
Hey all,

I have a ZFS pool in my proxmox box consisting of Seagate Enterprise drives.

They accept the smartctl -l scterc command to set the error recovery timeout, but unfortunately for some reason it is not persistent after reboot.

While reboots are infrequent, I don't want to forget to lower the default timeout when I do reboot, so I created a small script (well, less of a script and more of a list of commands) to run @reboot in cron.

the script looks like this:

Code:
# cat scterc.sh 
#!/bin/bash
smartctl -l scterc,20,20 /dev/disk/by-id/ata-ST10000NM0016-1TT101_Serial#1
smartctl -l scterc,20,20 /dev/disk/by-id/ata-ST10000NM0016-1TT101_Serial#2
smartctl -l scterc,20,20 /dev/disk/by-id/ata-ST10000NM0016-1TT101_Serial#3
smartctl -l scterc,20,20 /dev/disk/by-id/ata-ST10000NM0016-1TT101_ETC

It has been added to my root crontab as follows:
Code:
# m h  dom mon dow   command
@reboot /root/scterc.sh
If triggered manually, the sript works just fine, using smartctl to set the timeout for every disk in the pool, but at reboot not so much.

I just rebooted for the first time since setting it up, and got th efollowing notification in my email:

Code:
Title: Cron <root@proxmox> /root/scterc.sh 

Cron Daemon <root@proxmox.home.local>
1:00 AM (10 hours ago)

 to root 
/root/scterc.sh: line 2: smartctl: command not found
/root/scterc.sh: line 3: smartctl: command not found
/root/scterc.sh: line 4: smartctl: command not found
/root/scterc.sh: line 5: smartctl: command not found
/root/scterc.sh: line 6: smartctl: command not found
/root/scterc.sh: line 7: smartctl: command not found
/root/scterc.sh: line 8: smartctl: command not found
/root/scterc.sh: line 9: smartctl: command not found
/root/scterc.sh: line 10: smartctl: command not found
/root/scterc.sh: line 11: smartctl: command not found
/root/scterc.sh: line 12: smartctl: command not found
/root/scterc.sh: line 13: smartctl: command not found
As expected following this email, when I log on and check the scterc values, they have not been set as desired.

So for some reason, at reboot, the script cannot find the smartctl command? Does this @reboot command happen too hearly, before the binary path has been set, or maybe before smartd has properly started?

If so, how can I delay the execution to a point in time when it will work? Will a sleep line in my script do it, or will that just slow the boot and still be ineffective?

Or is ther something else going on here?

I appreciate any suggestions!
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
3,499
545
118
check the content of $PATH when called via cron ;)
 

mattlach

Member
Mar 23, 2016
154
12
18
Boston, MA
check the content of $PATH when called via cron ;)
Hmm.

I don't have the liberty to reboot at the time to troubleshoot exporting the path.

I'll try using the full path of the smartctl binary and see if that works ext time I reboot.

Do you know if the smartctl command requires smartd to be running?
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
3,499
545
118
Hmm.

I don't have the liberty to reboot at the time to troubleshoot exporting the path.
you can just run the cron job at some other point in time via cron?

I'll try using the full path of the smartctl binary and see if that works ext time I reboot.
should work (that, or setting PATH manually in the script)

Do you know if the smartctl command requires smartd to be running?
AFAIK, it does not.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!