I've created a launch agent that uses the find command to look in the downloads folder of a user

files_to_remove=(`cd ~/Downloads/ && find . \( -name "*.csv" -or -name "*.pdf" -or -name "*.sav" -or -name "*.tsv" -or -name "*.zip" -or -name "*.qsf" \) -mtime +5`)

Here is the plist file I've added to the LaunchAgents folder with a 10-second interval to help debug.

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
        <string>/Library/Application Support/downloadsCleanup/downloadsCleanup.sh</string>

Everytime the LaunchAgent runs is get the error find: .: Operation not permitted However, running the /Library/Application Support/downloadsCleanup/downloadsCleanup.sh script from the terminal prompts me to give permission to the terminal to access the downloads folder. Once the permission is granted the script works as intended.

I've added the .plist file and the .sh script to have full disk access but that that didn't change anything. What do I need to give access for this launchAgent to be able to execute the find command in the downloads folder?

1 Answer 1


Yes, you need to use

System Preferences -> Security and Privacy -> Privacy -> Files & Folders

Or maybe you can specify "Full Disk Access" for the last element there.

Grant /bin/bash access, and it should work.

  • I added /bin/sh to "Full Disk Access" and it worked! Thanks!
    – Josh
    Mar 23, 2020 at 17:57
  • I don't see /bin/sh listed here. What should I do?
    – a06e
    Dec 9, 2022 at 15:44

You must log in to answer this question.

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