Can't change name "python" in Background Tasks

I have a Python script that I've configured to run every 30 minutes. Since it has an associated property list, I've been trying to modify the name that appears in the 'Allow in the Background' section, but I couldn't find an effective way to display the desired name.

I tried setting the CFBundleName and CFBundleDisplayName keys in the .plist, but I don't believe they have any impact as they don't seem to change anything. Any other suggested approaches would be greatly appreciated.

This is the aforementioned property list:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
	<key>Label</key>
	  <string>com.tom.python-cleanup</string>
	<key>CFBundleName</key>
	  <string>Name that i want</string>
	<key>CFBundleDisplayName</key>
	  <string>Name that i want</string>
	<key>ProgramArguments</key>
	  <array>
	  	  <string>python</string>
		  <string>/usr/local/tom/cleanup.py</string>
	  </array>
	<key>StandardOutPath</key>
      <string>/usr/local/tom/cleanup-service.log</string>
    <key>StandardErrorPath</key>
      <string>/usr/local/tom/cleanup-service.log</string>
	<key>RunAtLoad</key>
	  <true/>
	<key>StartCalendarInterval</key>
	  <dict>
	    <key>Minute</key>
		    <integer>30</integer>
	  </dict>
  </dict>
</plist>

Replies

I tried setting the CFBundleName and CFBundleDisplayName keys in the .plist

You’re mixing up your property lists here. You’re working with launchd property list but those keys only make sense for a bundle’s Info.plist.

The Allow in the Background feature is really designed to be used by an app, using SMAppService, or by a daemon or agent associated with an app. If you don’t have an app, you end up relying on how the system infers the item’s name from its executable, and that’s tricky for something like a Python script.

You have a couple of options here:

  • Package your Python script into an app-like bundle and set its CFBundleName.

  • Create a completely separate app and use AssociatedBundleIdentifiers to associate your item with that. See the launchd.plist man page for details.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"