1

I've come across the following scenario in one of the servers I recently have to manage. Its an Ubuntu used as a music streaming server, the music must be changed according to an schedule but the last sysadmin did it manually with 3 scripts (00-stop.sh, 10-server.sh and 20-client.sh) Here are the steps he used/explained to me:

  1. Run 00-stop.sh script to stop the streaming server.
  2. Change the list in the 20-client.sh script.
  3. Run 10-server.sh using "&" to keep it running in the background.
  4. Run 20-client.sh with the updated list,music will start streaming.

I think I could use Cron automation to change the music automaticaly, but I'm not sure how to do it. My idea is to have four scripts: 00-stop.sh 10-server.sh 20-client.sh (with music list 1) 30-client.sh (with music list 2)

And run either 20-client or 30-client accordint to schedule. Each cron job should call 00-stop.sh first, then 10-server.sh (and keep it in the background) and then either 20-client.sh or 30-client.sh.

I imagine something like:

0 10 * * 1 /path/00-stop.sh && /path/10-server.sh && /path/20-client.sh

The problem is that I need the second script (10-server.sh) to keep running in the background, how could I do it?

1 Answer 1

3

I'd put together a single script:

#!/usr/bin/env bash
set -e   # abort for any non-zero exit statuses

/path/00-stop.sh

/path/10-server.sh </dev/null >/dev/null 2>&1 &
disown

/path/20-client.sh

Then the cron job would be

0 10 * * 1 bash /path/refresh_music_server.sh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .