Sh script to ping check internetconnection

Synology d.  08. maj. 2013, skrevet af @ngler
Vist: 776 gange.

@ngler
 
Redaktør
Tilføjet:
08-05-2013 15:05:23
Svar/Indlæg:
4033/364
Hi

Since my connection random disconnects I would like my DS213Air to check the connection.

a log tool would be great - but the Task planner (opgaveplanlægning) in the control panel can perhaps do this too.

I have made this script, running every hour:

#!/bin/sh
echo -e "\n" >> /volume1/Docs/checkconnection.log
ping -c 5 www.google.com
if [[ $? != 0 ]]; then
date '+%Y-%m-%d %H:%M:%S Connection Unavailable' >> /volume1/Docs/checkconnection.log
else
date '+%Y-%m-%d %H:%M:%S Connection Available' >> /volume1/Docs/checkconnection.log
fi

but the newline doesnt works, it keeps writing the all in one string :(

Any ideas or perhaps a tool so I can make my DS213air check for internet connection every 10 minutes or so?
KennethThomsen
 
Nørd
Tilføjet:
08-05-2013 20:15:23
Svar/Indlæg:
77/7
The internet says:

printf "\n" >> /volume1/Docs/checkconnection.log

instead of:

echo -e "\n" >> /volume1/Docs/checkconnection.log

Did you try that? It seems that some echo's doesn't support the -e parameter, so escaping doesn't work.


@ngler
 
Redaktør
Tilføjet:
09-05-2013 17:51:35
Svar/Indlæg:
4033/364
i notepad er det stadig i en lang køre, men i Notepad++ kan man godt se linjeskiftene :)