Hi All:
I want to write a program that runs like a service(in the background) and should start up when the system boots. It should always be running, no matter who has logged in, no matter if anybody has logged in et all.
Is there any online help i could get on this topic, appreciate the help
Thanks,
Preetham.
It's pretty simple to do in unix. No where near as complicated as it is in Win32.
You can execute your code with `nohup` (man nohup for more information) in the startup of your system. If need be, you should be able to sudo to any user you desire for this daemon for security purposes.
I use `nohup` with some network monitoring stuff that I do with tethereal and it works like a charm.
I got u r question ... u mean that it should run in back ground for ever till the server is rebooted.
What u have to do is
define the service in a program set the program in such a way that it should become the group leader.
setsid=getpid() ; /* This will make u r service the leader of u r group u belong to */
i don't remember the whole syntax in detail u can go thru the daemon concepts and find it out.
u can run this by manually running the program or setting this particular program in u r cron job if u have any difficulties in cron please feel free to contact me at sivhard@rediffmail.com
Why don't you just create a shell scripts and put it in /etc/rc.d/rc3.d and make a link over /etc/init.d/scripts-name. This should run when server boot up. (Linux)
If your program is written in C, your program should use the daemon() library call to make your program a daemon. This will cause your program to close its standard input, output, and error, and fork() into the background.
You should then add a command to one of your boot scripts to cause your program to run. The location of the script to change differs between Linux distributions. If you are running Red Hat, you should edit /etc/rc.d/rc.local. The script you need to edit is started directly or indirectly from /etc/inittab.
my-daemon.c: /etc/rc.d/rc.local:
Your daemon will run until the system shuts down, or until it crashes. Also, if your daemon has a memory leak, the kernel will kill it when it uses too much RAM.
If you make your program a non-daemon that closes its standard input/output/err, you can start it directly from inittab, with the action field set to "respawn". In this case, if your program crashes, init will restart it.
Hello Everyone,
Here I am offereing my Services
Word Posting Content Posting
PDF to excel or word
Image to Ms Word typeing
Document Creation
Video Creation
Any type Copy-Paste
Ads Posting
Article Posting
Manual Directory Submission
PR Submission
Social Bookmarking
Web 2.0 Blogs... (1 Reply)
Hi there;
I need to know all the things about services which help my Linux OS running.
So what're important services of LINUX OS ?
Anyone can help me...
Tks all ? (1 Reply)
Hi,
I want to write a service like windows service for my rhel4u5 server.And this service every day at 4:00 am connect a ftp server and download file then parse information at txt file then insert or update info at my database server(oracle).and this service can be stopped or paused by user.And... (1 Reply)
Hi
I am very new to Linux programming,otherwise I have exposure to Linux. Was thinking about something like writing my own commands for Linux. Any ideas where to start, any useful links and what I need to know before I start with this.
Thanks :)
Sidhu (3 Replies)
Hi there.
I've got 12 years experience writing C++ on Windows, and 3 years C# on Windows. Now my boss wants me to write a C++ app to run on Unix as a multithreaded 'service' (i.e. a program that runs with no user intervention).
Some quick questions for The Experts:
* Whats the best C++... (3 Replies)
Is it possible to save a file from linux environment to a windows ntfs partition?
I use SUSE 8.3 and I can access win ntfs files only as read only.
I want to know whether writing is possible on win ntfs partition. (2 Replies)
Yep, that's right.
I'm writing a Linux binary that requires an X11 Server. It will also be released in a Shell, Win32, and Cocoa (Mac OS X).
It's a program that's a text editor and more. It not just creates TXT and RTF files, it also can save in XML, RSS, and a whole lot of other formats.
... (11 Replies)
Has anyone here written an MS compatible .NET service that is hosted and served from a UNIX server instead of a W2K server? I love programming and writing .NET services with Visual Studio.NET and C#, but there is a fundamental problem --the Win2k server itself. It is not near as reliable as Sun... (0 Replies)