[SOLVED] Writing a script for my Synology Disk station to reboot if network lost
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Writing a script for my Synology Disk station to reboot if network lost
Hi
Linux is new to me but I know what I want it to do but can’t speak its language.
At least once a day my Synology Diskstation loses connection and it sends me an email. This however does not reestablish and The only way to get it back online is to reboot,
Having done some reading i don’t know if disabling and re-enacting the network would work.
So In a nutshell I need it to run a script in synology task manager to either reboot or disable and reenable network if connection to outside world is lost.
I'm not sure I understand your question and I know nothing about Synology DiskStation, but judging from their User's Guide there's a restart option inside Synology DiskStation Manager (DSM) (see page 12 of the guide).
I would like to know how to write a script that would restart the network connection if it is lost.
Something like ping 8.8.8.8 every 60 seconds
If no reply then restart the NAS.
I understand that I can do this manually but would like it automated. I have posted on the synology community and not got a reply. I also have emailed support and not heard back.
I would like to know how to write a script that would restart the network connection if it is lost.
Something like ping 8.8.8.8 every 60 seconds
If no reply then restart the NAS.
I understand that I can do this manually but would like it automated. I have posted on the synology community and not got a reply. I also have emailed support and not heard back.
A point I make near the start of that blog is the following:
Quote:
"Whatever you can type on a command line, you can write in a script."
Therefore I recommend that you learn how to write the very basic of a bash script, there are examples in that blog and plenty of examples and guides referenced there or available on the web, and put in the manual instructions you know how to perform.
Following that if you need assistance with making that script run automatically, such as with using cron, we can help you there as well. Please give a script an attempt with whichever language you like best to use.
If you have difficulty with the script, please post what you do have and describe the problems you are having. Please also review that blog for additional debug tactics one can use when writing and debugging bash scripts.
First hit on a simple search was this - and I didn't even have synology in the search.
Seems to cover what you want.
Quote:
Originally Posted by Newbuilder22
Thanks, when I tried simple search last night no results came up after waiting on the webpage load for 30 mins
Also, I can see that you tried web searching, assuming you were searching for something similar to the reference offered by syg00. Did you try to visit the link that they posted? I did and it works and also seems relevant.
Either option is what I'd pursue, writing a script yourself with help from members here, or trying that link+additional searching.
Create cron script that uses some mechanize to monitor network by some metric then take action such at reboot or telinit.
However all of that seems to me to be useless. I'd fix the reason it is losing "connection." Things like leases, tunnels and unique software from Synology may be the reason.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.