I have a bash script that does this:
nmap -sn 192.168.0.1-255 | grep -Eo 192.168.0.{1,3\}[0-9] > new.txt date >> network_log echo ---------------------------- >> network_log cat new.txt >> network_log Scans the network, and appends results to file network_log with a timestamp. After running it manually, the network_log file looks like this:
Tue 13 Sep 2016 11:22:23 EDT ---------------------------- 192.168.0.1 192.168.0.2 192.168.0.45 whereas the cronjobs produce the following outputs in my network_log file:
Tue Sep 13 17:46:00 EDT 2016 ---------------------------- with no ip results. Note: the cronjob is running from root user so it has all the elevation it needs to scan the entire network.
sudoto see if it's the cron or root user which makes a difference?grep -Eo '192\.168\.0\.{1,3\}[0-9]'(quoting)new.txt?