Reputation: 822
I'm new to python. I want to create controlled script executed from /etc/init.d command like /etc/init.d something start/stop/restart
Any advise appreciated.
Upvotes: 1
Views: 3009
Reputation: 16695
If you're looking for a module for constructing daemons. I've used this: https://gist.github.com/slor/5946334
Upvotes: 1
Reputation: 529
Pardus initialization (http://www.pardus.org.tr/eng/projects/comar/SpeedingUpLinuxWithPardus.html) is based on python and in theory you can even start system with windows executable (through Wine of course). You can see a sample initialisation script there doing almost same thing with shell script but in a pythonic way.
Upvotes: 1
Reputation: 2076
See this post on how to write a script to place in your /etc/init.d directory. The only difference is you must change the hash-bang line to point to python, and not bash:
#!/usr/bin/python
def myfunc():
print 'myfunct()'
if __name__ == '__main__':
print 'running python script'
myfunc()
And make the file executable
chmod +x myscript
Upvotes: 3