- Level 1
- Posts: 48
- Joined: Thu Apr 04, 2013 12:17 pm
I have a script I wrote to automate my backup to 2 places, a local hard drive and to a cloud storage service. I only want the cloud backup to run when I am at work because my home internet connection is not great. To achieve this in the script I check the id of the current network using iwgetid -r. The script works as I expected when I run it from the terminal, but when I run it in a crob job it does not identify the name of the current network. Here is a minimal example:
NetName=$( iwgetid -r )
echo $NetName >> someFile.txt
When I run this in a cron job it only appends a blank line to someFile.txt, but when I run from the terminal directly it appends the network id. What is going on here?
- Level 5
- Posts: 953
- Joined: Fri Sep 05, 2014 12:18 am
- Location: Britisher...
How are you using Cron? Via a crontab or scripts dropped into one of the
If the former you may need to specify the full path to
iwgetid in the script or probably more convenient expand crons $PATH e.g by adding a line like this to the relevant crontab -