diff --git a/how-to-disable-cups-printer-job-history-on-macos/README.md b/how-to-disable-cups-printer-job-history-on-macos/README.md index 3c6415e..f67acfd 100644 --- a/how-to-disable-cups-printer-job-history-on-macos/README.md +++ b/how-to-disable-cups-printer-job-history-on-macos/README.md @@ -2,7 +2,7 @@ Title: How to disable CUPS printer job history on macOS Description: Learn how to disable CUPS printer job history on macOS. Author: Sun Knudsen -Contributors: Sun Knudsen +Contributors: Sun Knudsen , Carl P. Corliss Reviewers: Publication date: 2022-10-29T13:05:18.112Z Listed: true @@ -34,7 +34,7 @@ sudo mkdir -p /usr/local/sbin sudo chown ${USER}:admin /usr/local/sbin ``` -### Step 3: create `cups.sh` script +### Step 3: create `cups.sh` script (see CUPS [docs](https://www.cups.org/doc/man-cupsd.conf.html)) ```shell cat << "EOF" > /usr/local/sbin/cups.sh @@ -42,15 +42,11 @@ cat << "EOF" > /usr/local/sbin/cups.sh set -e -if grep -qe '^PreserveJobHistory Off$' /etc/cups/cupsd.conf; then +if cupsctl | grep --quiet PreserveJobHistory=no; then exit 0 fi -echo "PreserveJobHistory Off" | sudo tee -a /etc/cups/cupsd.conf - -sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist - -sudo launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist +cupsctl MaxJobTime=5m PreserveJobFiles=no PreserveJobHistory=no EOF ``` @@ -62,6 +58,8 @@ chmod +x /usr/local/sbin/cups.sh ### Step 5: create `local.cups.plist` launch daemon +> Heads-up: used to make sure user-defined config persists macOS updates. + ```shell cat << "EOF" | sudo tee /Library/LaunchDaemons/local.cups.plist @@ -91,32 +89,24 @@ EOF ## Want things back the way they were before following this guide? No problem! -### Step 1: delete `PreserveJobHistory Off` line from `cupsd.conf` - -```shell -sudo sed -i "" "/PreserveJobHistory Off/d" /etc/cups/cupsd.conf -``` - -### Step 2: delete `cups.sh` script +### Step 1: delete `cups.sh` script ```shell sudo rm /usr/local/sbin/cups.sh ``` -### Step 3: delete `local.cups.plist` launch daemon +### Step 2: delete `local.cups.plist` launch daemon ```shell sudo rm /Library/LaunchDaemons/local.cups.plist ``` -### Step 4: reload CUPS +### Step 3: revert user-defined config to CUPS defaults ```shell -sudo launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist - -sudo launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist +cupsctl MaxJobTime= PreserveJobFiles= PreserveJobHistory= ``` -### Step 5: reboot +### Step 4: reboot 👍