I have scheduled a task arp -a
which runs once per hour, that scans my wi-fi network to save all the info about currently connected devices into a scan.txt
file. After the scan, a python script reads the scan.txt
and saves the data into a database.
This is what my wifiscan.sh
script looks like:
cd /home/pi/python/wifiscan/
arp -a > /home/pi/python/wifiscan/scan.txt
python wifiscan.py
This is my crontab task:
#wifiscan
59 * * * * sh /home/pi/launcher/wifiscan.sh
If I run the wifiscan.sh
file manually, all the process works perfectly; when it is run by the crontab, the scan.txt
file is generated empty and the rest of the process works, but with no data, so I'm assuming that the problem lies in the arp -a
command.
How is it possible that arp -a
does not produce any output when it is run by crontab? Is there any mistakes I'm making?
As @Mark Setchell commented, I solved my problem by launching the command with its entire path (in this case, /usr/sbin/arp
)