Cronjob Shutdown Script

Hi Guys,

shortly i migrated from Core to Scale. Since this, my Cronjob Script isnt working anymore. It gives out the error:

EFAULT] CronTask “/mnt/RAIDZ-6x2TB/shutdowncheck.sh” exited with 137 (non-zero) exit status.

Error Name: EFAULT
Error Code: 14
Reason: [EFAULT] CronTask “/mnt/RAIDZ-6x2TB/shutdowncheck.sh” exited with 137 (non-zero) exit status.
Error Class: CallError

Could anyone say me how i can get my script working to shutdown the NAS`?

I think the following cron job should work. Haven’t tested it.

  • Command: midclt call system.shutdown CRONJOB
  • Run as User: root

Edit: Maybe post your current script if you need to do more than just initiate a shutdown.
Edit2: Looks like system.shutdown requires a reason now.

If the script uses bsd specific commands and syntax it would be normal to not run under sclae since it’s linux based.
If you’re using api calls it may also be that core uses the old depreciated rest api and scle uses the newer websocket api

Command: midclt call system.shutdown CRONJOB

Can you show me how this would be looking in the scrpt? i had written the command in the script, but Here is may script.

How can i post the script here? For new users its not possible to attach files, and its not possible to share links.

Do you mean the command midclt call system.shutdown?

I have read about it, but i hadnt get it to worked in a script. I became the same error, when i write it in the script.

Try somethinglike this:

/usr/bin/midclt call system.shutdown “Sleep” as user root

I had put the command in my script and replaced it to “shutdown -p now”, but it shows the same error. I can not send screenshots in the posts as new user.

can you take a look over my script? but how can i send it to you?

I have 0 knowledge about scripting, sorry i wouldn’t be any help

Press the </> button in the forums message editor toolbar, and then paste the complete contents of the script file at the designated spot. You do not need to upload the file, its contents is fine, since it’s just text.

Please do so.

Here is my Script:

#!/bin/bash
HOST1=192.168.1.14 #IP des ersten PC
HOST2=192.168.1.19 #IP des zweiten PC
HOST3=192.168.1.24 #IP des zweiten PC
HOST4=192.168.1.41 #IP des zweiten PC
HOST5=192.168.1.42 #IP des zweiten PC
ip_range=192.168.0. #Netzadresse des eigenen Netzwerkes ohne den Hostanteil
ip=40 #checke Netz ab IP-Adresse 40

_exit () {
case $1 in
	1) echo "Kein Shutdown - Mindestens einer der PCs ist eingeschaltet" ;;
	2) echo "Kein PC online - Shutdown" ; /usr/bin/midclt call system.shutdown “Sleep” ;;
esac
exit $1;
}

# Checken ob PC's an sind
if [ `ping -c 1 -i 1 $HOST1 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST2 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST3 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST4 | grep -wc 100.0%` -eq 0 ] || [ `ping -c 1 -i 1 $HOST5 | grep -wc 100.0%` -eq 0 ] ; 
then _exit 1; # abbrechen, ein PC läuft
# Wenn kein PC an ist, gehe zu Checken ob PC's im IP-Bereich an sind
else

# Checken ob PC's im IP-Bereich an sind
	while [ $ip -le 45 ] #checke Netz bis Hostanteil 45
do
	ping -c 1 -i 1 $ip_range$ip #ping mit der zusammengesetzten IP-Adresse aus den o.a. Variablen "ip" und "i"
	if [ `ping -c 1 -i 1 $ip_range$ip | grep -wc 100.0%` -eq 0 ] #sobald einer der Hosts auf den ping antwortet, nicht herunterfahren
then _exit 1 #beenden mit exit 1 (kein shutdown)
fi
 ip=$(( $ip+1 )) #erhöhe Hostanteil immer um 1
done

_exit 2 # hat kein PC geantwortet, shutdown
fi

Can you take a look to my script? If i put the command in the cron directly, it goes on. But with this i can’t control the Shutdown over the Script. I had tried to put the command in a blank script, it gives also an Error.