Only run CRON job if connected to specific wifi network
Posted
by
Herbert
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Herbert
Published on 2012-06-13T21:30:18Z
Indexed on
2012/06/15
15:27 UTC
Read the original article
Hit count: 274
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
© Ask Ubuntu or respective owner