LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2019, 09:36 AM   #16
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308

Quote:
Originally Posted by lgrech25 View Post
Yes the script is executable. In fact it works perfectly fine. Only in crontabs it doesn't work

-rwxrwxrwx 1 admin19 admin19 104 Feb 15 16:22 HostDiscovery
So what does /tmp/logfile say after the modification as per my previous post?
 
Old 02-15-2019, 09:40 AM   #17
lgrech25
LQ Newbie
 
Registered: Feb 2019
Posts: 6

Original Poster
Rep: Reputation: Disabled
It worked Guys Thanks a lot. After changing the directory and implementing everything in the sudo crontab -e. It updated 2/3 minutes after because of the namp process. Sorry for bothering you a lot
 
Old 02-15-2019, 09:43 AM   #18
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,748

Rep: Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927
crond will detect when /etc/crontab has changed and reload the file so there is no need to restart the service.

I agree with joe_2000 that it should work and it does from my debian system. The changes I made were to add a space between -d and
' ' in the cut command and add an absolute path to the output file.

Code:
*/5 * * * * root /usr/bin/nmap -O 192.168.0.1-253 | grep 'Nmap scan' | cut -d ' ' -f5 > /tmp/HostList
 
1 members found this post helpful.
Old 02-15-2019, 09:43 AM   #19
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by lgrech25 View Post
It worked Guys Thanks a lot. After changing the directory and implementing everything in the sudo crontab -e. It updated 2/3 minutes after because of the namp process. Sorry for bothering you a lot
Cool. So in summary, the original problem was that the output file ended up in some other location than you expected? Probably /root ?

Either way: It's good advice from TBOne to use crontab -e as this will also do syntax checking on your crontab entries and complain if the syntax is wrong.
 
1 members found this post helpful.
Old 02-15-2019, 09:45 AM   #20
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by michaelk View Post
The changes I made were to add a space between -d and
' ' in the cut command and add an absolute path to the output file.
imho the space is not required
 
Old 02-15-2019, 09:49 AM   #21
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,748

Rep: Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927Reputation: 5927
It shouldn't, when I tested the command I had a to fix a typo...
 
Old 02-15-2019, 09:52 AM   #22
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by michaelk View Post
It shouldn't, when I tested the command I had a to fix a typo...
Code:
$ echo "foo bar" | cut -d' ' -f 2
bar
...runs fine over here :-)
 
Old 02-16-2019, 04:24 AM   #23
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by lgrech25 View Post
Yes the script is executable. In fact it works perfectly fine. Only in crontabs it doesn't work

-rwxrwxrwx 1 admin19 admin19 104 Feb 15 16:22 HostDiscovery
rwxrwxrwx is a security fail as it allows anyone to takeover your account.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
port 5432 open nmap online but closed status with firewalld and local nmap scan mtdew3q Linux - Security 6 06-04-2018 06:20 PM
nmap ? how do i do nmap in linux ? command not found abbasakhtar Linux - Newbie 2 01-02-2011 01:08 AM
LXer: Learn how to use nmap, and nmap GUI, a great port scan tool LXer Syndicated Linux News 0 01-03-2008 09:10 AM
nmap increase send delay for nmap 4.20 matters Slackware 1 10-01-2007 11:37 PM
Cant nmap from but can nmap to procfs Linux - General 6 08-01-2006 02:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration