2

I wrote a bash script that backs up certain files on my computer. To automate the running of the script, I set up an associated daemon that runs the script every day.

There are certain instances when I would like the daemon to print error messages. For instance, my script depends on my directory structure and it will run incorrectly if I move certain directories. If the directories on my system do not match those in the script, I would like the daemon to convey an error message so that I can update the script.

Here's the problem: if I were just running the script in the terminal, I could easily have it print an error message to the terminal. But when the daemon runs the script, it does not print anything to the terminal. (Does the daemon print to anything? Where does the printed text go?)

I can see several ways for the daemon to tell the user about an error:

  1. Use the wall command in the script to print the error to all users
  2. Use the launchctl -list command to manually check the exit code of the daemon (which the user has to remember to do)
  3. Hve the script write to some external, user-created error/log file (which the user has to notice/check)
  4. Use ASL or Syslog (see the Mac Developer Library) to e.g. write the error to an .asl file

Option 1 seems too simple. Options 2 and 3 feel unsatisfactory because they only work if the user remembers to check something. I don't know much about Option 4, but it seems built for more complicated types of errors.

What is the recommended way for a daemon to tell the user about an error? (Is this a question for Stack Overflow?)

  • 1
    Option 5 Send an email? And I don't see it as a SO question. You don't have an explicit problem to solve. You are looking for a recommendation as how to do something in general. – Peter M May 8 '16 at 17:25
  • Option 6: create an Automator workflow that gives you an error in a window when it finds one? – agentroadkill May 8 '16 at 18:40

You must log in to answer this question.

Browse other questions tagged .