Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-23-2004, 05:03 AM   #1
LQ Newbie
Registered: May 2004
Location: Auckland, NZ
Distribution: Debian Etch
Posts: 19

Rep: Reputation: 0
Cron Mystery / Perl

Im working on a ip accounting exercise to log traffic on a NAT router. (following the NAG2 guide). See thread :

In order to clear the iptables counters I have set a cron job (as root) using crontab <file>

5 3 * * * perl /root/

this perl script looks like :

-rwx------ 1 root root 1373 May 23 20:55*

$_ = `iptables -L -v`;

The script runs on schedule, but the syscall to iptables fails (silently). It appears as though its not running as root, which the iptables command requires. Ive tried all sorts of things, read the man pages (poor) some good tuts at:

The script works fine manually as root, but not under cron. Hmmm.

BTW a related problem ive noticed is that the shebang syntax for perl scripts dont work for some reason.

whereis perl
perl: /usr/bin/perl

-rwx------ 1 root root 1373 May 23 20:55*

[root@fileserver root] ./
bash: ./ bad interpreter: No such file or directory

works ok

Any ideas on those two probs?
Old 05-23-2004, 10:47 AM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
Try using the full path to iptables:
$_ = `/sbin/iptables -L -v`;

Assuming that iptables is in /sbin
Old 05-23-2004, 06:11 PM   #3
LQ Newbie
Registered: May 2004
Location: Auckland, NZ
Distribution: Debian Etch
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks, that cracked it. Silly late night mistake.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Email Notification - Perl Script jamesyreid Programming 3 07-21-2009 07:56 AM
Cron and Perl question eagle683 Programming 3 07-30-2005 08:28 PM
Cron problems with perl slice Linux - Newbie 1 02-21-2005 10:49 AM
Trouble with perl script in Cron job thack111 Linux - General 7 11-25-2004 02:44 AM
how to make a cron entry? (perl) akaash Programming 2 05-06-2004 02:15 AM > Forums > Linux Forums > Linux - General

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

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