Install the app
How to install the app on iOS

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

Task Schedule Help: Will This Script Work?

As an Amazon Associate, we may earn commissions from qualifying purchases. Learn more...

1
0
NAS
DS 718+, DS 716+II
Router
  1. RT2600ac
Operating system
  1. Windows
Mobile operating system
  1. iOS
I have both a DS 718+ and DS 716+II. I'm trying to make something work and I'm a bit out over my skis. I thought I'd check with the experts here to see if I am on the right track, or, headed for a crash.

Synology user for 13 years. NOT a linux expert. Don't know CLI syntax/commands but follow advice and commands and use it when necessary.

I have two Syno NAS -- one for my business -- one for personal. Have business internet with 5 IP addresses. Two routers on different IPs for domain ID purposes so they really are separate networks. Just had my first power crash in 13 years. Rebuilding the business NAS now -- had backups fortunately.

To prevent this problem in the future I bought a UPS that could support both NAS -- but -- I didn't think about the fact they are on separate networks. Only one USB port for connection. So, while ONE NAS and the routers can be on the UPS, I don't think I can put the second on and use the DSM integrated UPS management.

I was thinking that perhaps I could have one of the NAS -- the one that won't be connected via DSM -- PING the other NAS (and a couple of other sites like google and facebook), periodically, and if they are down, to automatically shut down. If I pinged say every 8 minutes and had a 5 minute shut down on the primary, I should be able to run for say 20-30 mins and eventually the pings won't work and it will shut down. I asked ChatGPT to help me craft a script to put into the "remote" NAS Task Scheduler and it gave me the following: MY QUESTION: Does this look like it would work, AND, is there any danger to putting this script in? Any thoughts would be appreciated. Thanks in advance!
ChatGPT's script:

#!/bin/sh
SITES=("example1.com" "example2.com" "example3.com") # Replace with the domains you want to ping
PING_COUNT=1
PING_INTERVAL=15
TOTAL_DURATION=120
SLEEP_TIME=480 # 8 minutes in seconds

while true; do
end_time=$((SECONDS + TOTAL_DURATION))
all_unresponsive=true

while [ $SECONDS -lt $end_time ]; do
for SITE in "${SITES[@]}"; do
count=$(ping -c $PING_COUNT $SITE | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -ne 0 ]; then
all_unresponsive=false
break
fi
done

if ! $all_unresponsive; then
break
fi

sleep $PING_INTERVAL
done


It then says to make the script executable using this:

chmod +x /path/to/your/script.sh


Finally these are the chatGPT instructions:

  1. Schedule the Script:
    • Use Synology’s Task Scheduler to run this script at startup or at regular intervals.
This script will:

  • Ping multiple specified domains every 15 seconds for a total of 2 minutes.
  • If all domains are unresponsive during this period, it will shut down the NAS.
  • The script will then wait for 8 minutes before running again.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Popular tags from this forum

Similar threads

Thanks for your advice, I was able to figure it out. There was two folders located in /var/packages. One...
Replies
2
Views
692
Welcome. QuickConnect is unique and paired with a dedicated NAS system (serial number) so having a single...
Replies
1
Views
599

Thread Tags

Tags Tags
None

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending content in this forum

Back
Top