Only run CRON job if connected to specific wifi network
- by Herbert
I am a newbie to scripting on Linux (Lubuntu), but I would like to make a script that runs a cron job only if my laptop is connected to my home wifi.
Is this possible?
I guess, I could do something with iwconfig and pull the ESSID from there with grep?
So far, I tried this and it seems to work:
#!/bin/bash
# CRON, connected to specific WIFI
clear
netid=HOFF216
if iwconfig | grep $netid
then
clear
echo "True, we are connected to $netid"
rsync ...........
else
clear
echo "False, we are not connected to $netid"
fi