2

I use linux, e.g. Pepermint OS. There is a mysql table, there is numeric field as a flag. The table only has 1 record. If the field contain 1, I want to play a short mp3 once an then update the field to 0/zero again. There is an application that can play mp3 from command prompt, e.g mpg123.

To play the mp3, I use the following script :

import subprocess
call = "mpg123 ting_tong1.mp3 & "
p = subprocess.Popen( call, shell=True, stdout=subprocess.PIPE,   stderr=subprocess.STDOUT)

I want the script run in the background, like a service in Windows. I have been trying night and day with several daemon library in python, but no luck.

There should a music sound e.g. the mp3 sound, every time the field changed from 0 to 1 !

The daemon run but the music only run once :( . How to do that ? Thanks !

Wibowo Margito
  • 57
  • 1
  • 1
  • 9

1 Answers1

4

You can try the nohup command to start a daemon process and the watch command to repeat the command after a specified time.

call = "watch -n0 nohup mpg123 ting_tong1.mp3 &"

You can add >out.txt 2>err.txt, otherwise std output and error is stored in a file called nohup.out

Community
  • 1
  • 1
seenorth
  • 17
  • 1
  • 9