Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Script:

#!/bin/bash
today=$(date +"%Y-%m-%d")
tempfilename=/home/directedition/observatory/scan-$today.temp.xml
filename=/home/directedition/observatory/scan-$today.xml
touch $tempfilename
chmod 640 $tempfilename
/usr/bin/nmap -A -T5 -O -v -oX $tempfilename 10.10.1.0-255 > /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.

share|improve this question
    
Can you edit your post with the exact CRON entry, as well as your complete script file? –  BryceAtNetwork23 Apr 9 '13 at 12:33

1 Answer 1

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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