MacOS – Cleaning Up Temp Files and Bash Periodics

macosmaintenanceterminal

Every night, I run the following commands in Terminal before shutting down my Mac, but I wonder if I should just enter them in the same directory that my Terminal appears in (/Users/myUserName) or should I cd to a particular directory?

rm -rf ~/.bash_history
rm -rf .TemporaryItems
rm -rf .Trash
sudo periodic daily
sudo periodic weekly
sudo periodic monthly
history -c

Best Answer

Ignoring for a moment that the daily, weekly, monthly jobs are running automatically anyway, you need to make sure that you are either in the correct directory or using absolute paths when running rm:

rm -rf /PATH/TO/.TemporaryItems
rm -rf ~/.Trash