I have a shell script that runs nmap on an address, and I want to have it do it daily for me. So I added a reference to it in my crontab.

Unfortunately, for some reason it doesn't recognize the arguments I'm sending to nmap. While it runs fine when I run it explicitly, it errors in cron on the first argument.

Cron entry:

0 3 * * * /home/directedition/observatory/nmapscan.sh # JOB_ID_1


today=$(date +"%Y-%m-%d")
touch $tempfilename
chmod 640 $tempfilename
/usr/bin/nmap -A -T5 -O -v -oX $tempfilename > /home/directedition/observatory/nmapoutput.txt
chown directedition $tempfilename
chmod 644 $tempfilename
mv $tempfilename $filename

Error: nmap: invalid option -- 'A'

I can shuffle the arguments around, and whichever I put first will invariably error.

  • Can you edit your post with the exact CRON entry, as well as your complete script file? – Aaron Apr 9 '13 at 12:33

Try to use the full path of the executing program like:

0 3 * * * /bin/bash /home/directedition/observatory/nmapscan.sh # JOB_ID_1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.