Launchd Job Always in the Background

When I schedule automated tasks (e.g. python code) via launchd, it always runs in the background.

Since, the code is still not robust I need to be looking at the output in real time to make sure it is working OK.

How can I keep terminal window open and visible while the code runs?


P.S. I have already set up log files that I check after the code has run, but, I want to see output in real time.


Thank you.

Posted on Sep 23, 2018 1:22 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 23, 2018 2:30 PM

Hello,

You can try "tail -f" on the log files. But this can be sensitive to how you write the log files. For example, it won't work if you are writing an entirely new copy of the file with something like vi. But if you keep the same file open and just append to the end, it should be sufficient.

Similar questions

3 replies

Sep 26, 2018 3:11 PM in response to sinsinfromquincy

I had a request in the support communities late spring this year to provide a pop-up dialog informing the user when their battery level was below a specified percentage. It was implemented as a Launch Agent, rather than a Launch Daemon, because the latter suppresses GUI responses. The Launch Agent runs every 15 minutes, and passes the low water mark battery level as an integer to the Bash script that it executes. I stuck the .plist and .sh files in ~/Library/LaunchAgents, and a simple logout/login was all that was necessary to start the agent.


The Bash script compares the passed integer value to the current battery level, and using a Python HERE document, launches a custom PyObjC Alert dialog reminding the user to plug in their charger. Otherwise, the Bash script exits.


This means that you can place graphical (Tk, PyObjC, osascript) dialogs at strategic locations in your Python script to show progress when it runs, or create a non-GUI Python logging function to write progress to a Desktop file.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Launchd Job Always in the Background

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.