time base

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.

time base

Postby venky145 » Wed Jan 17, 2007 5:40 pm

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.
venky145
Havaldaar
 
Posts: 118
Joined: Thu Jan 13, 2005 2:35 pm
WLM: ranga72
Yahoo Messenger: venky145
Location: qatar

Postby kbukhari » Wed Jan 17, 2007 8:02 pm

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
kbukhari
Major General
 
Posts: 1222
Joined: Sat Dec 31, 2005 12:29 am
Website: http://kashifbukhari.com
Location: Lahore

Re:

Postby LinuxFreaK » Thu Jan 18, 2007 4:10 pm

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
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi

cron probl

Postby venky145 » Wed Jan 31, 2007 4:51 pm

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
venky145
Havaldaar
 
Posts: 118
Joined: Thu Jan 13, 2005 2:35 pm
WLM: ranga72
Yahoo Messenger: venky145
Location: qatar

Re:

Postby LinuxFreaK » Wed Jan 31, 2007 5:57 pm

Dear venky145,
Salam,

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

Best Regards.
Farrukh Ahmed
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi


Return to “%s” Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron