time base

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
venky145
Havaldaar
Posts: 118
Joined: Thu Jan 13, 2005 2:35 pm
Location: qatar
Contact:

time base

Post by venky145 »

hi

I want to execute one script every night 9.00 and stop or kill that script that script morning 9.00 clock.

how can i do it.

executing is no problem to using cron job but how to killing the process automatically.
kbukhari
Major General
Posts: 1222
Joined: Sat Dec 31, 2005 12:29 am
Location: Lahore
Contact:

Post by kbukhari »

u can use killall <process name>
Last edited by kbukhari on Fri Jan 19, 2007 11:57 am, edited 1 time in total.
--
Syed Kashif Ali Bukhari
+92-345-8444420
http://sysadminsline.com
http://kashifbukhari.com
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear venky145,
Salam,

Use crontab to achieve this goal.

Code: Select all

1 18 * * * exec /path/to/the/run.script
1 09 * * * exec /path/to/the/kill.script
Best Regards.
Farrukh Ahmed
venky145
Havaldaar
Posts: 118
Joined: Thu Jan 13, 2005 2:35 pm
Location: qatar
Contact:

cron probl

Post by venky145 »

hi

# this is my firewall
iptables -t nat -F
iptables -F
echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -p tcp -s 0/0 -d 0/0 --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A POSTROUTING -p tcp -o eth0 --dport 5050 -j MASQUERADE
iptables -I INPUT -p tcp -s 0/0 -d 0/0 --dport 3128 -j DROP
iptables -t nat -A PREROUTING -p tcp -s 0/0 -d 0/0 --dport 5050 -j REDIRECT --to-port 3128

/sbin/iptables -t nat -A POSTROUTING -s 20.20.1.1/32 -d 0/0 -j MASQUERADE
/sbin/iptables -I INPUT -p tcp -s 20.20.1.1/32 -d 0/0 --dport 3128 -j ACCEPT

# this is my night pack script

/sbin/iptables -t nat -A POSTROUTING -s 20.20.1.2/32 -d 0/0 -j MASQUERADE
/sbin/iptables -I INPUT -p tcp -s 20.20.1.2/32 -d 0/0 --dport 3128 -j ACCEPT

# this is my cron job
* 21 * * * exec /bin/night
* 09 * * * exec /bin/fwall


in 20.20.1.1 IP is UNlimited pack and 20.20.1.2 if night 9 to morng 9 pack

cron job is executing night 9 and i am getting internet of 20.20.1.2 but morng 9 it's not stoping internet access of 20.20.1.2

if i manually execute the fwall script its working fine.
pls help me
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear venky145,
Salam,

Check this, http://www.linuxpakistan.net/forum2x/vi ... php?t=6553

Best Regards.
Farrukh Ahmed
Post Reply