-   Linux - Software (
-   -   How-To Write a Linux Daemon (a question) (

animehair 04-08-2006 09:12 PM

How-To Write a Linux Daemon (a question)
I want to write a cron script or daemon that will scan a given directory for torrent files, and seed them. Then it will stop the process at a certain time. The reason I want to do this is because bittorrent KILLS my internet connection. I want to share, but its not feasible during working hours. So I figured I could create an automatic way of sharing during off-peak morning hours.

Would someone point me in the right direction to get started on this.

btmiller 04-08-2006 10:23 PM

I'd write two little shell scripts, one to seed all the files and the other to kill all the bitorrent processes. Have cron run the first whenever you want to start the seeding and the second when you want to shut it down. The killall command might be useful for the second script (e.g. killall bittorrent would kill all the bittorrent processes. If you don't want to kill every last one, you could write a more advanced script to check the process start time (grep the ps aux results) and kill only those started at the same time your first job ran. A little hackish, but it should work.

animehair 04-09-2006 07:51 AM

What if I wanted to incorporate logging to track total upload/dowload MB for each torrent? Can you do that with a simple bash script?

Progmaker 04-09-2006 08:10 AM

Some time ago I wound a very good article, how to write a deamon on Linux: "Linux Daemon Writing HOWTO". This is on the C programming language:

animehair 04-10-2006 07:00 AM

hmm, ya that article is pretty good. thanks...probably the cron script would be the easiest method, but Im going to try both methods.

Progmaker 04-10-2006 10:46 AM

Yeah, so do I liked this article, becouse I want to create a Linux firewall, so I need to know, how to put a program in memory :)
But, I think, I'll write a Linux module better... :)

All times are GMT -5. The time now is 01:44 PM.