当前位置: 动力学知识库 > 问答 > 编程问答 >

user controls - job scheduling in linux

问题描述:

I want to schedule access to some website for a limited period of time say for 1 hour every day. How can i do that using cron job in linux. or can i do that using linux squid server?.

网友答案:

In /etc/crontab:

0 18    * * *   root    /etc/init.d/apache start
0 19    * * *   root    /etc/init.d/apache stop

The apache service will start at 18:00 every day, and stop at 19:00 every day. Adjust as needed for your distro's init script structure.

网友答案:

It matters what you want to happen when the site isn't accessible. You could simply only have Apache start for that time. You could use iptables (or another firewall) to not allow connections on port 80. You could also just edit configuration file and deny all with Apache on that website.

Give a bit more detail on what you want to do.

网友答案:

if you do go the iptables route (which may not be the best way to do this), you can use the "time" module in iptables, as in:

iptables -A -m state --state NEW,ESTABLISHED -p tcp --dport 80 -d -m time --timestart 1800 --timestop 1900 -j ACCEPT

网友答案:

I am not 100% sure what you are asking - are you talking about running a httpd (Apache) that is hosted on your server and allowing someone to check the site at a particular time maybe a demo site for someone or are you an administrator who wants to impose restrictions on web surfing within your network? If your answer is yes to the second question, I think this question should be moved across to superuser.com.

I guess William's answer combined with cron, one could schedule to refuse packets (incoming/outgoing) within iptables for port 80/443, at all times other then the times specified in the cron job. You would have to make sure that this does work as you will have to clear the iptables each time so you would need to save the iptables configuration dump to a file somewhere.

As for Squid, you can check here.

Hope this helps, Best regards, Tom.

分享给朋友:
您可能感兴趣的文章:
随机阅读: