We help top organizations stay competitive, by implementing the latest disruptive technologies.

Latest Posts

Adjust the LANDESK Mac SDCache Purge Schedule

Adjust the LANDESK Mac SDCache Purge Schedule

In my previous post, I discussed how you could push down a script to a Mac to clean up the LANDESK SDCache folder, potentially recovering precious hard drive space.

This script process described previously, while quick and efficient, is more of a band-aid and doesn’t necessarily address the problem of binaries being kept too long on the Mac – especially those with super small hard drives.

While having an SDCache folder full of binaries can be helpful, especially on bandwidth constrained networks as other clients can pull directly from that local Mac as opposed to the source file share, you may find you just need to shorten the number of days some of your Macs keep files within the SDCache folder to save yourself the headaches from the help desk calls complaining that their machine is out of hard drive space.

The XML file that controls the schedule for the SDCache purge is located in the /Library/Application Support/LANDesk/scheduler folder and is titled ldcron-sdclean.xml.


If you crack that file open with a text editor, you’ll notice it contains the same command line text we used to purge the SDCache folder manually.

find /Library/Application\ Support/LANDesk/sdcache/* -mtime +45 -exec rm -rf {} \;

All you need to do is copy off the ldcron-sdclean.xml file from one of your machines or download an example from my GitHub repository, and adjust the -mtime +45 to align with your needs.  Setting a value of +10 will tell LANDESK to purge any file within the SDCache folder older than 10 days, +3 would purge any file older than 3 days and so on.  So set the appropriate value, using your favorite text editor, and then save the updated file to one of your file repository shares.

Now we need to create a Mac package to deploy out the updated ldcron-sdclean.xml file to all of the Macs that need to be updated.  I’ve written a script, again available on my GitHub page, titled changeSDCachePurgeTime.sh that will do exactly that. Basically, it uses the LANDESK sdclient tool to download the XML file and place it into the /Library/Application Support/LANDesk/scheduler folder.

In order for you to use the script, you just need to change the fileToCopy variable path to match the location you saved your ldcron-sdclean.xml file to.  Other than that, it should be totally ready to go.


# changeSDCachePurgeTime
# Created by Bennett Norton on 9/21/16.
# This script will copy the updated SDCache XML to the target machine with the updated sdcache time purge

#Script Variables
#change the IP address to match your http package share hosting the updated ldcron-sdclean.xml file
destinationLocation="/Library/Application Support/LANDesk/scheduler"

#sdclient downloads the license key and the kav addkey applies the key
/Library/Application\ Support/LANDesk/bin/sdclient -noinstall -package "$fileToCopy" -destdir "$destinationLocation"

If you decide to write your own script, just make sure you set the execute permissions on the file prior to copying it to your file share.

sudo chmod +x /path/to/script.sh

Now you’re ready to create your Mac package and deploy.  The directions to so do are below.

Creating LANDESK Management Suite Mac Packages

  1. Open the LANDESK Console
  2. Navigate to the top menu bar, select Tools > Distribution > Distribution Packages.
  3. In the lower left menu tree, highlight My Packages or Public Packages from within the Distribution Packages window
  4. On the Distribution menu bar, press the New Package button and select New Macintosh Package.
  5. Give the package a name
  6. Provide a description as well as any metadata information desired
  7. Set the primary file to the script file you previously transferred to your package share
  8. Fill out the Metadata details if desired, specifically supplying a logo so it shows up properly in the portal
  9. Save the package

Creating a Scheduled Mac Software Distribution Task

  1. Right click on the Mac software distribution package created and select Create Scheduled Task
  2. From the network view, select and drag the desired machine(s), user(s) or query(ies) and drop them onto the task
  3. Now, right click on the task and select properties
  4. Set the desired Task type under Task Settings as to whether you want a push, a policy or a hybrid of the two types in a policy-supported push
  5. Set the radio button in the Portal Settings to either Recommended or Optional if you desire to put the package into Workspaces.  If you’d like to automatically deploy the app, select Run automatically
  6. Change the Reboot Settings or Distribution and Patch settings if desired
  7. Set the schedule task settings with the appropriate start time

Problem totally solved, right?

Well, not quite.  If at any time in the future you redeploy the LANDESK Mac agent, the ldcron-scheduler.xml file will be overwritten with the default +45 day value.  You could always write a custom definition, if you’re a LANDESK Patch customer, and watch for that value and remediate if detected.  However, that may be more work than its worth to you, if you only have a couple of machines you’re concerned about.  So just be cognizant that an agent deployment will reset the value and redeploy your package if need be.


No Comments

Post A Comment