Hello everyone i am facing issues with ram memory so every 1 hour I open the terminal on my mac os and type in purge to free up memory. I wanted to know how to write the shell script and cron it.
Doing kernel related (like flushing buffers) either requires high level access (e.g. Execute by root/uid0) or a way to elevate to that level. The last is usually done by making a file either uid or guid 0 (root:root or root:wheel) and setting the suitbit. Ls -l on the purge binary will show if that bit is set. ( The $( ) starts a subshell and returns the value. In this case it is intended to locate the binary and then feed that output to the ls command. Akind to which purge - purge is in /some/folder/purge and then doing a ls -l /some/folder/purge.
(all from the shell ofc) – Nov 8 '13 at 16:12. Answer blatantly copied from: You need to run this command with root privileges. You can do that in several ways: 1) Elevate one command to uid 0 rights with the sudo command: sudo purge WARNING: Improper use of the sudo command could lead to data loss or the deletion of important system files. Please double-check your typing when using sudo. Type 'man sudo' for more information. To proceed, enter your password, or type Ctrl-C to abort. Password: Enter your account's password and it should run the purge command.
If you do not want to enter a password, add%localaccounts ALL=NOPASSWD: /usr/sbin/purge to sudoers. (From a shell run sudo visudo, press i, type or paste the text, press escape, and type:wq.) Then use a Run Shell Script action that runs sudo purge. 2) Log in as root and issue the command.
Optionally 3) From your terminal prompt (a bash shell) type su -, the root password and then /usr/sbin/purge. Apple probably made the decision for security purposes.
The only disadvantage is you have to type in your admin password. The advantage is, for non-admin users, they can not run this command and potentially harm their OS. Usually commands that require sudo in order to run at all are potentially destructive or invasive. Two other commands with this requirement are dtrace and xcode-select.
The amount of free space on your hard drive is in question. Some application says you don't have enough free space to do something with 1 GB of data (such as iTunes cannot backup your iPhone to the local computer!). Finder says something like 200 GB are free. Disk Utility says 200 GB are free, but 199.9 GB are Purgeable. Those numbers are made up. See my screenshot for my actual situation.
If you're like me, you thought, 'Where's the Purge button?' Well, the only one we find is in the back of our throat. You read articles. You do not have Optimize Mac Storage turned on and never have. You have hooked your computer up to your Time Machine backup and let it run overnight, plugged in and turned on without closing the lid (just in case, you know, something wtvrs.) You read MOAR articles. You turn on Optimize Mac Storage. You let it do its thing for a day.
Nothing changes. You turn it back off. You wait a day. Nothing changes. You turn off Automatic Backups in Time Machine. You wait a day. Nothing changes.
![Purging Purging](/uploads/1/2/4/3/124309316/105264035.jpg)
Then you start reading all sorts of fun things in Terminal tmutil disablelocal is an Unrecognized verb. Nothing else works. And then you start to mash the info together. HERE IS WHAT I CAME UP WITH: Open Terminal. Df -h See list of volumes / drives. Find the one you care about. It is not always /dev/disk1.
For example, here's mine: Filesystem Size Used Avail Capacity iused ifree%iused Mounted on /dev/disk1s1 605Gi 420Gi 184Gi 70% 1207649 0% / devfs 185Ki 185Ki 0Bi 100% 640 0 100% /dev /dev/disk1s4 605Gi 1.0Gi 184Gi 1% 1 854775806 0% /private/var/vm /dev/disk0s3 94Gi 59Gi 35Gi 64% 23481 1% /Volumes/BOOTCAMP map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net map autohome 0Bi 0Bi 0Bi 100% 0 0 100% /home I find that /dev/disk1s1 is my largest volume and the stats noted corespond to my actual local drive space usage. Now do this: diskutil secureErase freespace 0 /dev/disk1s1 See something like a percentage meter and such. Let the thing do its work. When it is done is looks like this: Started erase on disk1s1 Macintosh HD Creating a temporary file Securely erasing a file Creating a secondary temporary file Mounting disk Finished erase on disk1s1 Macintosh HD NOW go look at Finder and Disk Utility. It worked for me. BUT you really should make sure the simpler things do not work for you, first.
Dear Apple Developers: Statistically NOBODY knows that local Time Machine Snapshots are being made. Your OS doesn't just make room for new data by eliminating snapshots on the fly. It might be supposed to, but it don't. So, since we can't see your magic hidden data and you don't give us an option to work this out, we end up screwed and having to go muck about in the Terminal. Just so that we can, in my case, make a complete local backup of my iPhone SO THAT I CAN WIPE RESET AND REINSTALL IT. No Love, All Of Us.
PS - Stop doing things like this. Purgeable does not equal unnecessary, unwanted, extraneous, or otherwise something you want to purge. They are files that the OS detects have a copy on iCloud and could be deleted if you need the space. From what I can tell, show up as Purgeable. Sometimes, local snapshots can get stuck and won't delete. There is information in the linked FAQ on how to turn them on or off in Terminal, but as that website hasn't been updated since the death of its author, you might have to check other sources if those methods don't work.
I think you've missed the point, here. You wrote, '.you may have to search somewhere else to find someone who actually knows how. To cause the Snapshots to disappear.' The method I outlined actually works and is not outdated, which is more than can be said for every other article I found on the issue on these forums. This isn't wailing and gnashing. It's called Technical Support.
![Purging Purging](/uploads/1/2/4/3/124309316/902505541.png)
You should try sometime. Or at the very least, stop failing to show how smart you are by proposing an outdated solution that doesn't work. As someone frustrated by this issue and being clueless when it comes to computers, I really appreciate your posts. I tried your method but sadly it didn't work for my main drive. I copy and pasted your text ( /dev/disk1s1 appears to be my main drive). Terminal did the '0%.10%.20%.30%.' Thing but on checking the drive Info and Disk Utility after it ran it appears I still have 100GB of purgeable data.
Apple states that “In macOS Sierra, “Purgeable” content appears when you've turned on.' Where's the advice for macOSHigh Sierra?!
If I follow the advice for macOS Sierra then the inference is that if I DON'T turn on 'Optimize Mac Storage', then purgable data ought not to appear. But it DOES appear so what purpose does the Apple statement serve? None other than to confuse and confound their customers. I see someone thought it useful to provide an Apple 'Feedback' link. ' We read all feedback carefully, but we are unable to respond to each submission individually.' - The Apple feedback page.
With all due respect I don't want to provide feedback, I want a solution. Apple Footer.
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple may provide or recommend responses as a possible solution based on the information provided; every potential issue may involve several factors not detailed in the conversations captured in an electronic forum and Apple can therefore provide no guarantee as to the efficacy of any proposed solutions on the community forums. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the.