0

My script mystreaming.py listens to Twitter Streaming API (from my feed) and inserts tweets into the MySQL table. It works, fully tested. However, now I want this command to keep executing even when I exit from a shell prompt (I need to let it run on my node in linode). I use nohup, but it doesn't seem to get the job done.

So I'm doing:

nohup mysql &
nohup python mystreaming.py < /dev/null > /dev/null 2>&1 &

However, when I check my tables, looks like the most recent tweet was before 11:59pm, and nothing is added after that. However, clearly new tweets were posted on my feed since then. Any idea what can cause this problem? Thanks a lot!

Arman
  • 1,074
  • 3
  • 20
  • 40

2 Answers2

2

An easier solution that robustly solves your problem: invest in a terminal multiplexer like GNU Screen or tmux. This has the added benefit of allowing you to reconnect to the session should anything go horribly wrong.

For kicking these jobs off during startup with logging support, consider using your crontab or /etc/rc.local, as well.

MrGomez
  • 23,788
  • 45
  • 72
0

The proper solution is probably to make your ruby script into a Daemon. Check out Make a Ruby program a daemon?

But if it were me, I'd probably just run it in GNU Screen. See e.g. http://spin.atomicobject.com/2011/04/29/gnu-screen-crash-course/

Community
  • 1
  • 1
Eli
  • 5,500
  • 1
  • 29
  • 27