i’ve got a Rut956 i want to use for a research project.
The RUT has to do the following steps every 60min:
Close the relais
WoL of a different computer
Oben relais after x min
I put everything in a script (with echo to monitor which state the script is in):
while true
do
echo "Start"
ubus call ioman.relay.relay0 update '{"state":"closed"}'
/sbin/api post /wol/actions/wake_all_devices
# Output to keep track of status
for i in $(seq 1 720)
do
echo 720-$i
done
ubus call ioman.relay.relay0 update '{"state":"closed"}'
echo "Waiting"
# Output to keep track of status
for i in $(seq 1 2880)
do
echo 2880-$i
done
i know, it might not be the most elegant way but as long as it works im happy.
Due to some initial setup when starting the reseach i want to start the script via CLI.
Therefore used the following which I#d like to start one the setup is done.
chmod 777 /root/Ablauf.sh
Now comes the problem, i want to be able to check the status vie RMS - more precisely the echo-output from the script to make sure everything is running.
Is there any way to get the CLI to display the echo after reconnecting to it?
I als othought about using crontab but I’m not to familiar with it and scared to mess it up and losing data.
I also thought about sending a sms from time to time - would that be more useful?
You can view echo outputs in logs (e.g., logread or the system.log file) by replacing echo with logger -t YourScriptName.
For example, if I want my script to output the word “test” in logs, I would use the logger command instead of echo: logger -t MyScript "Start"
After the script executes, the desired output will appear in the router logs:
In your case, you can modify your script like this to ensure all outputs are saved and displayed in the logs:
while true
do
logger -t YourScriptName "Start"
ubus call ioman.relay.relay0 update '{"state":"closed"}'
/sbin/api post /wol/actions/wake_all_devices
# Output to keep track of status
for i in $(seq 1 720)
do
logger -t YourScriptName 720-$i
done
ubus call ioman.relay.relay0 update '{"state":"closed"}'
logger -t YourScriptName "Waiting"
# Output to keep track of status
for i in $(seq 1 2880)
do
logger -t YourScriptName 2880-$i
done
Regarding crontabs, we have a wiki page with detailed explanations and examples that should be helpful. It’s simpler than it might seem at first.
You can also execute a script via SMS. To do this, navigate to SMS Utilities and add a rule to execute a custom script. In the rule configuration, you can specify your script. For more details, refer to our Mobile Utilities wiki page.
Please let me know if you have any further questions or need assistance.