Help - Search - Members - Calendar
Full Version: Problem With Cron
Linuxhelp > Support > Technical Support
hi all
i've made an executable file /bin/test
it is being properly executed when i type just "test" or "/bin/test" as root

now i tried to execute this file at a specific time through cron. this is what i've done

crontab -e

then i gave the following entry and saved it

30 23 * * * root /bin/test

it is supposed to be execute at 11.30 pm ... but itz not executing

i also tried

30 23 * * * /bin/test

but same problem.

m i in wrong track ??

What does /var/log/cron have to say?
now i think problem is not with cron wacko.gif
cause when i do entry followings:

00 20 * * * /sbin/reboot

the system got reboot at 10 pm .

i think i m wrong in creating executable file sad.gif

suppose i wanted to delete a client (ip from my entire network.
route add -host reject # ( is there anyother way ?? cause when i reboot my system the this ip comeback again)

i've made the file /bin/test and type following in that file:

route add -host reject

then i type

chmod 755 /bin/test

now if i type "/bin/test" or just "test" the ip is added in my routing list and this ip cant do anything.
as this command work properly i thought it'll execute autmaticly with corn. but now i think i've to do something else to use this command with corn.

oh ! at 23:00 the /var/log/corn says:

Nov 29 23:00:00 proxy CROND[11878]: (root) CMD (/bin/test)

if i m not wrong i think it tells that CORN has made his job at right time. problem is my /bin/test command can't be executed in this way.

thank u all !! may be i need help abt writing executable file rather then corn. sad.gif
Why dont you just put the full command into cron?

30 23 * * * root route add -host reject
cause i need to route add serveral ips at a time . if my executable script is as followings:

route add -host reject
route add -host reject
route add -host reject

then i need to change the time only once in my cron script

The problem is that while you are logged in as root, you have root's path ... but when the cron executes it doesn't have root's path....

either put this line in the top of the executable script test:


source root's .bash_profile so all environmental variables root normally has are there:

source /root/.bash_profile

Or use the full path to all commands inside the script like this:

/sbin/route add -host reject

But ... why do this as a cron (where it is going to executed once per day). This seems to me to be a static command that needs only to be executed once at startup....unless you plan to open the IP's at one time and close them at another...

Also, using route add -host reject is not firewalling (see man route on your system) .... you can't see the PC's in question or connect to them, but they can see your PC and make connections to you....all you are changing is your outbound route table.

If you are trying to prevent those PC's from connecting to your computer ... or if this a IPMASQUARDE / NAT router and you want to block internet access, then iptables is the way to go.
thanx ,
now itz working smile.gif
would u plz explain me what this PATH and source acctually tells ??

yap......i wana allow some ip to use internet only at 12 am to 8 am
thats y planned to write two executable file which will be executed at 12 am and 8 am respectively.

at 12 am :
route add -host reject
and so on..........
at 8 am:
route del -host reject

i m working on NAT router. would u plz give me any idea abt how iptables can handle it ??

thanx a lot again .......
PATH is a list of directories where items will try to be executed (in order from left to right) if a full path is not supplied ... so if you type the command:


instead of /bin/ps, then each directory is searched to see if there is a ps....

If your PATH is


then /usr/local/sbin is checked for ps ... if there is a ps there it is run. If no ps in /usr/local/sbin, then /usr/local/bin is checked for ps ... etc, until ps is found, then it is run.

You can use the command:

which ps

to find which executable is run when you type ps ...
The command source executes a script and resets your environmental variables based on that script ... and root's environment is set via /root/.bash_profile, so doing the command:

source /root/.bash_profile

would set the environment of the script to the environment of the user root....
What you are trying to do might work ok .... if so, you can use it. If it doesn't do what you want, let me know and we'll work on a set of rules for iptables.
ok sir,
itz working in my way. the problem is if i reboot the server.. everything is deleted frm route :S
jut tell me how can i control it through iptables. let me put the inforamtion again:

my external interface connected with internet is eth0 (
my internal interface connected with LAN is eth1 (
my linux9.0 is being used as router.
i want to allow some ip (, ... and so on) to access internet at specific time (say from 10:00 pm to 10:00 am)

how iptables can handle it ??

thanking in advance
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.