taskpolicy - macOS


Overview

taskpolicy is a command-line utility for managing macOS system task policies. It allows users to create, modify, and delete task policies, which control the CPU and memory resources allocated to specific processes and applications. By optimizing task policies, you can improve system performance, prioritize critical applications, and save energy by reducing unnecessary resource usage.

Syntax

taskpolicy [options] <command>

Commands:

  • create – Create a new task policy
  • modify – Modify an existing task policy
  • delete – Delete a task policy
  • show – Display information about task policies
  • interactive – Launch an interactive interface for managing task policies

Options/Flags

  • -h, –help – Print usage information
  • -v, –verbose – Enable verbose output
  • -d, –debug – Enable debug output
  • -s, –system – Apply policy to all processes on the system
  • -a, –app – Apply policy to a specific application or process

Examples

Create a new policy:

taskpolicy create --name my-policy --cpu-limit 50 --memory-limit 1GB

Modify an existing policy:

taskpolicy modify --name my-policy --cpu-limit 75

Delete a policy:

taskpolicy delete --name my-policy

Show policy information:

taskpolicy show --name my-policy

Launch interactive interface:

taskpolicy interactive

Common Issues

  • Policy not applied: Ensure that the policy is applied to the correct application or process. The -a flag can be used to specify specific targets.
  • Permission denied: The command requires administrative privileges. Use sudo to run the command with elevated permissions.
  • Resource allocation errors: Ensure that the specified CPU and memory limits are valid and do not conflict with system requirements.

Integration

taskpolicy can be integrated with other macOS commands and tools to optimize system performance. For example:

  • Use with powermetrics to monitor system resource usage and identify potential areas for optimization.
  • Integrate into scripts or automation workflows to automatically manage task policies based on specific conditions.
  • ps – Display running processes
  • top – Monitor system resource usage
  • launchctl – Manage launch daemons and agents