LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Starting a job at startup without logging in (https://www.linuxquestions.org/questions/linux-software-2/starting-a-job-at-startup-without-logging-in-847514/)

Phaethar 11-30-2010 01:58 PM

Starting a job at startup without logging in
 
Hey all,

Kind of an interesting project here. I'm trying to think of the best way to have a job start up on it's own when a system (running CentOS 5) boots up. The job is a simple python script. However, there are some interesting conditions that need to be met:

- As stated, script needs to start and run in the background when the system boots up, but without anyone logging in.
- This script needs to be readable only by root, which means it will need to be run as root
- Only 1 person will have root access, meaning nobody else will have access to see this script or it's status.

The entire point is to have this thing running all the time, even if the system reboots, but to make it so nobody can see the script or view it's source, unless they have root access, which only 1 person will have.

I can think of plenty of ways to have things start up automatically when a system comes up, but they all involve having the user log in as part of it. How can I have a listening python script start up, at boot up, on it's own, without root actually logging in?

AlucardZero 11-30-2010 02:06 PM

Use the @reboot facility in root's crontab, or create your own init script with symlinks in the right runlevels. http://wiki.linuxquestions.org/wiki/...tartup_scripts

forrestt 11-30-2010 02:42 PM

My suggestions are:

1) Forget about the running the script as root. Create a non-root user specifically for this task and run the script as that user. The root user will still be able to "read" it, and limiting it to one locked down user + root isn't really any different.

2) Stating only one user will have access to root is not true if the script is run as root. One user plus anybody else who can circumvent this script would have access to root. Only one person would have access to root if it is run as a different user even if someone circumvents it.

3) Without knowing much more about the functionality of the script, I would say run it as a daemon rather than w/ cron.

HTH

Forrest


All times are GMT -5. The time now is 12:04 AM.