You mention needing it to run after a user logs in, but that it runs until the system is shut down. That's a bit conflicting, because usually things that would run in an X session would stop when the session is shut down. Additionally, if you want it to run on a non-X-windows session, you'll have to be very careful about how it reacts with running multiple times or be careful to start it only once.
That said, here are some ways to run scripts:
- In a user crontab use "@reboot" for the time specification, like:
@reboot /path/to/script This will cause it to run as the specified user, and will start at system boot time and run until either it dies or the system is shut down.
- Go into the "Settings" application (XFCE: Applications -> Settings -> Xfce 4 Settings, GNOME: System -> Preferences, etc) and modify the applications that are started for your session. You can add a script to run as part of the session. This will start and run while your session is running, but it won't be restarted if the script dies.
- The session script could be wrapped by a script that runs the Python program in the background, so that it would continue running after session logout, but then you have to make sure that if a user logs out and back in that they don't start multiple copies.
- If you want it to run from shell sessions via SSH or the like, rather than an X windows session, you could put it in the .profile (.bash_profile, .zprofile, etc). But you're going to need to background it as above and be sure multiple copies aren't running.
- You could just put it in /etc/rc.local and either run it as the user (via "su"), but that's going to start at boot time, not login time. Personally, I'd recommend cront+@reboot over this.
- You could create an upstart script in "/etc/init", this will cause it to start at boot time as above, but you can make it restart the script if it dies for any reason. This is the best option if you need to make sure it continues running.