Issue with launchd Job Not Running – "Bootstrap failed: 5: Input/output error"

# Purpose

I want to use launchd to run a shell script asynchronously every minute, but I'm encountering an issue where the job does not run, and I receive the error "Bootstrap failed: 5: Input/output error". I need help identifying the cause of this issue and how to configure launchd correctly.


# What I've done

## Created the shell script (test_ls_save.sh)

The script is designed to list the contents of the desktop and save the output to a specified directory.

------------------------------------------

#!/bin/bash

DATE=$(date +%Y-%m-%d_%H-%M-%S)

SAVE_DIR=/Users/test/Desktop/personal/log_gather

FILE_NAME="ls_output_$DATE.log"

ls ~/Desktop > "$SAVE_DIR/$FILE_NAME"

echo "ls output saved to $SAVE_DIR/$FILE_NAME"

------------------------------------------

File permissions (ls -l output): -rwxr-xr-x 1 test staff 1234 Feb 17 10:00 /Users/test/Desktop/personal/log_gather/exec/test_ls_save.sh


## Created the launchd plist file (com.test.logTest.plist)

The plist file is configured to execute the shell script every minute.

------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.test.logTest</string>

<key>ProgramArguments</key>

<array>

<string>/bin/bash</string>

<string>-c</string>

<string>/Users/test/Desktop/personal/log_gather/exec/test_ls_save.sh</string>

</array>

<key>StartInterval</key>

<integer>60</integer> <!-- Run every minute -->

</dict>

</plist>

------------------------------------------

File permissions (ls -l output): -rwxr-xr-x 1 test staff 512 Feb 17 10:00 /Users/test/Library/LaunchAgents/com.test.logTest.plist



## Ran the job with launchctl

I used the following command to load the plist file into launchd:

------------------------------------------

sudo launchctl bootstrap gui/$(id -u) /Users/test/Library/LaunchAgents/com.test.logTest.plist

------------------------------------------


## pc spec

MacBook Pro

Apple M1

16 GB RAM

macOS 15.3 (Build 24D60)


## what I know

  • The configuration has been set, but the launchd job is not running every minute as expected.
  • I don't believe there is a mistake with the path.
  • When I check the job using launchctl list, the job does not appear in the list.
  • I don't know where the error log files are supposed to be. I checked /var/log/system.log, but there are no error logs.
  • The .sh file runs fine by itself, but it cannot be executed via launchctl.


## Want to ask

  • What could be the cause of the launchd job not running as expected?
  • Also, is there a way to check where the logs are being output?
  • If there is an error in the plist file configuration, which part should be modified?
  • Specifically, what improvements should be made regarding environment variables and path settings?


If my information is not enough, please tell me what is not enough!

MacBook Pro 13″

投稿日 2025/02/17 10:02

返信
返信: 2
並べ替え順: 

Issue with launchd Job Not Running – "Bootstrap failed: 5: Input/output error"

Apple サポートコミュニティへようこそ
Apple ユーザ同士でお使いの製品について助け合うフォーラムです。Apple Account を使ってご参加ください。