Update 3
The script I am using in the cron entry for the Omega2+ on the Power Dock:
# !/bin/ash -e
# Filename: my1.sh
# Description: Controls the Omega2+ LED
# Rapidly pulses the LED
echo timer > /sys/class/leds/omega2p\:amber\:system/trigger
echo 75 > /sys/class/leds/omega2p\:amber\:system/delay_on
echo 75 > /sys/class/leds/omega2p\:amber\:system/delay_off
sleep 4
echo default-on > /sys/class/leds/omega2p\:amber\:system/trigger
cat /sys/class/leds/omega2p\:amber\:system/trigger
date
Turns the LED on to rapid pulse for 4 seconds, then resets the LED to ON then displays the trigger status and date, then exits.
The cron entry to invoke the script every minute.
root@Omega-6049:~# crontab -l
# MM HH DD MM DOW
#*/1 * * * * /root/squote.sh >> /tmp/output.txt 2>$1
*/1 * * * * /root/my1.sh > /tmp/output1.txt 2>$1
# last line must be a comment
[Edit] as @György-Farkas posted below the error is in the crontab entry. I mistakenly entered a $ instead of an &. The 2>&1
is an indicator to the shell script that you want to include the error messages into the output of your command.
root@Omega-6049:~# crontab -l
# MM HH DD MM DOW
#*/1 * * * * /root/squote.sh >> /tmp/output.txt 2>&1
*/1 * * * * /root/my1.sh > /tmp/output1.txt 2>&1
# last line must be a comment
snapshot of ps to show the cron is operational
root@Omega-6049:~# ps | grep cron
9098 root 1188 S /usr/sbin/crond -f -c /etc/crontabs -l 8
12240 root 1184 S grep cron
At the moment (or a second after) the cron should invoke the script there should be an entry in the process list to show that it is running.
root@Omega-6049:~# ps | grep sh
1845 nobody 1292 S /usr/sbin/shellinaboxd -t --service=/:LOGIN --css /usr/lib/shellinabox/style.css
1857 nobody 1292 S /usr/sbin/shellinaboxd -t --service=/:LOGIN --css /usr/lib/shellinabox/style.css
8505 root 1192 S -ash
11322 root 896 S /sbin/askfirst /usr/libexec/login.sh
12342 root 0 Z [sh]
12345 root 1184 S grep sh
As you can see there is no line matching that would indicate that my1.sh is running except that process number 12342 is suspect.
On my other Omega2+ (which is working as expected on the Expansion Dock) the script I am running on the minute is as follows:
#!/bin/ash -e
# Filename: my.sh
# Description: Controls the Omega2+ LED
echo timer > /sys/class/leds/omega2p\:amber\:system/trigger
echo 75 > /sys/class/leds/omega2p\:amber\:system/delay_on
echo 75 > /sys/class/leds/omega2p\:amber\:system/delay_off
sleep 4
echo default-on > /sys/class/leds/omega2p\:amber\:system/trigger
cat /sys/class/leds/omega2p\:amber\:system/trigger
date
The cron entry (the second one).
root@Omega-B779:~# crontab -l
# MM HH DD MM DOW
*/1 * * * * /root/rgb-control.sh > /tmp/output.txt 2>&1
*/1 * * * * /root/my.sh > /tmp/output1.txt 2>&1
# last line must be a comment
root@Omega-B779:~#
snapshot of the ps just after the minute mark
root@Omega-B779:~# ps | grep sh
453 root 896 S /sbin/askfirst /usr/libexec/login.sh
2430 nobody 1292 S /usr/sbin/shellinaboxd -t --service=/:LOGIN --css /usr/lib/shellinabox/style.css
2439 nobody 1292 S /usr/sbin/shellinaboxd -t --service=/:LOGIN --css /usr/lib/shellinabox/style.css
13521 root 1184 S /bin/sh -c /root/rgb-control.sh > /tmp/output.txt 2>&1
13522 root 1184 S /bin/sh -c /root/my.sh > /tmp/output1.txt 2>&1
13523 root 1184 S {my.sh} /bin/ash -e /root/my.sh
13524 root 1184 S {rgb-control.sh} /bin/ash /root/rgb-control.sh
13527 root 1184 S {rgb-led.sh} /bin/sh -e /root/rgb-led.sh
13774 root 1184 S grep sh
18469 root 1184 S -ash
Process number 13523 is in progress so on this Omega2+ everything is working nicely.
The contents of the output1.txt file to show that the process ran as expected.
root@Omega-B779:/tmp# cat output1.txt
none timer [default-on] netdev transient mmc0 gpio heartbeat morse oneshot
Sun Feb 12 12:39:04 AWST 2017
root@Omega-B779:/tmp#
If I swap the suspect Omega2+ from the Power Dock to this one (Expansion Dock), the issue with the cron still exists so it is not Dock related.
Any ideas?