0

I wanted to stop and restart a function in python at regular interval[let's say 1 hour], were function contains os.system();#needed command

Inside os.system, an cvlc program is trying to capture stream and saving in local disk. I need to stop at each one hour , and will be providing new file name for next start.

Sample code will be appreciated...!

jOSe
  • 687
  • 11
  • 22
  • 3
    Your try will be much appreciated .. :) – Iron Fist Jul 11 '15 at 05:55
  • I've tried and it's not happening. Do I need to use subprocess library in python? – jOSe Jul 11 '15 at 05:58
  • 2
    Just Post what your tried and will help you.. – Iron Fist Jul 11 '15 at 05:59
  • I've imported threading in python & I created two functions. One contains the os.system line and another function which is as follows 'code' threading.Timer(6.0,save()).start() 'code' – jOSe Jul 11 '15 at 06:04
  • 1
    @jOSe edit it in your answer, write a code snippet. people here wont write entire code but they will only suggest you the improvements. – Ja8zyjits Jul 11 '15 at 07:59
  • `code threading.Timer(6.0,save()).start() ` Thank you for the suggestion – jOSe Jul 11 '15 at 08:50
  • 1
    Please a minimal example or the full code to your post! The one-liner is not helpful. – Klaus D. Jul 11 '15 at 09:20
  • I've got the solution, apart from using 'threading' I've imported 'subprocess' – jOSe Jul 11 '15 at 11:15
  • For production on Linux I would consider making your python program into a service so it could be stopped and started from a bash service script. Then a cron job could be created for it that would stop and start it every hour. Some information about how to make an executable into a Linux service is at http://stackoverflow.com/questions/22336075/linux-process-into-a-service. –  Jul 11 '15 at 13:56

0 Answers0