DS218+ how to restart networking and/or clear SMB cache on schedule?
Why Do Network Services Restart?
How to stop restart a synology service from SSH access | Synology Community
networking - Automatically restarting network connection - Unix & Linux Stack Exchange
Videos
It turned out for few days for unknown reason my SMB share from my DS218+ was not accessible to other Windows machines and I didn't notice and I didn't get any alerts. I saw similar issues in the past and I was not able to find a reason. The only thing that works 100% is clearing SMB cache. Then that share (accessed by ip, e.g. \\192.168.1.181\home from Windows machines) becomes readily available.
I'd like to have that cache clear on autopilot nightly - how would I do that?
There are several packages that can govern/manage the network. NetworkManager and wicd are 2 that I'm familiar with. You can run these both from the command line, and they can fully manage the network. You could leverage either to check if the network is in a up/usable state and to initiate a restart if connectivity is lost.
If the device is providing a service like Upstart/Systemd you can also put rules into place at that level to trigger restarts when internet connectivity is lost.
- Make Network Manager restart after dropped connection?
Something from cron
If you're limited in what you can do in terms of the software available to you on your Synology box, you could run something from cron every couple of minutes.
if ! ping -Q 1 -c 1 -t 1 google.com; then
ifdown eth0
sleep 3
ifup eth0
fi
References
- Method to check connectivity to other server
Using the script above (slightly tweaked) as below running in the task scheduler each minute. You could use cron instead but it is nice to have in the gui.
if ! ping -I wlan0 -c 1 google.com; then
ifconfig wlan0 down
sleep 5
ifconfig wlan0 up
fi
Is anyone using a package or something simple to setup to monitor services running on Synology and possibly restart them?
For example, my Plex Media Server crashes from time to time and I have to manually got to Package Centre and hit "Run". Is there anything out there that can keep an eye on it, detect the crash (checking service status or doing http request to Plex endpoint), report it and restart?
You can start and stop a service in the Task Scheduler. I am assuming that would work with PMS as well. So - assuming it does - one option would be to stop PMS every night, say at 3am and restart it at 3:15am (or something like that).
However it would probably be better, if you start digging into the logs to find out, why PMS has crashed and fix the root cause.
Not the most elegant solution, but if it only locks up after running for some time, you could use task scheduler to stop and restart it regularly.
On DSM6, I could restart the SSH service using sudo synoservicectl --restart sshd, but this doesn't work anymore on DSM7 (7.0.1-42218 Update 2): -sh: synoservicectl: command not found.
Does anyone how to start/stop/restart services (more specifically, SSH) from the command line?
I know that SSH can be restarted from the DSM GUI, by untoggling/saving/toggling/saving "Enable SSH Service" in Control Panel > Terminal & SNMP > Terminal, so that's not what I'm looking for.