Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

running MAC OS X maintenance scripts manually in terminal mode

I'm trying to run the maintenance scripts manually in terminal but I get the error message "-bash sudo: command not found"
and the same when I try to determine when the scripts were last run "-bash: ls: command not found"

I'm using the command (in Panther)

sudo periodic daily weekly monthly

to run them all

and

ls -al/var/log/*.out

to check when they were last run.


Thanks.

Peter

G5 Mac OS X (10.3.9)

Posted on Jun 8, 2007 8:12 AM

Reply
18 replies

Jun 8, 2007 4:10 PM in response to Peter Robertson

Peter
-bash sudo: command not found
You have something seriously wrong with your Terminal and/or bash setup, but we'll get to that later.

For the moment, try

/usr/bin/sudo periodic daily weekly monthly

and let us know if it works. BTW, the weekly script takes some time, so you may want to try it with just the "daily" script first.

To check when they were last run, use:

/bin/ls -al /var/log/*.out

and note there is a space after "-al", which doesn't appear in your post.

In fact you may want to copy and paste those commands to avoid any typos.

Let us know if this works, when quoting the full path, and we can try to reinstate the default path for you. Does echo "hello" work?

Jun 9, 2007 4:29 PM in response to Michael Conniff

I tried

/usr/bin/sudo periodic daily

and

/usr/bin/sudo periodic weekly

and I get

sudo: periodic: command not found

/bin/ls -al /var/log/*.out

worked and told me that it's been a while since the scripts have run.

echo "hello" returns

hello

One other question--which directory should I be in when I try to run these scripts? Right now I am in the directory which comes up when I open the terminal window. I have only a very basic understanding of the terminal window--I do alot of applescripting--but I would like to fix this problem.

Thanks for your help.

Peter

Jun 10, 2007 10:34 AM in response to Peter Robertson

Peter
sudo: periodic: command not found
Ah! I forgot the full path for periodic 😟 Try what Niel posted: that will work.

Now to fix your $PATH. First, open Terminal > Preferences. Under "When creating a new Terminal window:", do you have the first radio button selected? The one that says "Execute the default login shell using /usr/bin/login"? If not, select it. Also the "Open a saved .term file…" checkbox should not be checked. If you need to change these, do so, then quit Terminal and restart it.

Then copy and paste the following into the Terminal window, one line at a time, with a return after each line:

echo $PATH
/usr/bin/more /etc/profile

Copy and paste the results, including the commands, from the Terminal window to a post here.
One other question--which directory should I be in when I try to run these scripts?
If we get your $PATH right, it won't matter. When you start Terminal, you are automatically in your Home directory "/Users/<yourname>", abbreviated as '~'. You can always check which directory you are in with pwd (or /bin/pwd until we get your $PATH working).

Jun 14, 2007 2:01 PM in response to Michael Conniff

Thanks. Here are the results. The big space between the profile command and the result was the way it displayed in my terminal window.

Peter


Last login: Thu Jun 14 16:53:50 on console
Welcome to Darwin!
You have mail.
Peter-Robertsons-Computer:~ peterrobertson$ echo $PATH
.:/usr/local/bin
Peter-Robertsons-Computer:~ peterrobertson$ /usr/bin/more /etc/profile













# System-wide .profile for sh(1)

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH

[ -r /etc/bashrc ] && source /etc/bashrc
Peter-Robertsons-Computer:~ peterrobertson$

G5 Mac OS X (10.3.9)

Jun 14, 2007 4:48 PM in response to Peter Robertson

Peter

Your /etc/profile is OK (I had to mount a 10.3.9 volume to check, because it has changed slightly in 10.4).

The big space between the profile command and the result was the way it displayed in my terminal window.

That's normal for more or less when the file is shorter than the Terminal window—it will fill to the bottom.

Somewhere your path is being wrongly set. Obviously, someone wanted to add ".:/usr/local/bin" to your path, but instead is overwriting it. The first thing to note is that adding '.' to your path is a security risk. If you really must have it, you should put it at the end. I never use it: I have a ~/bin directory for my own private stuff and add that to my path instead.

Now to this path corruption. First, move ~/Library/Preferences/com.apple.Terminal.plist to your Desktop, restart Terminal and repeat the echo $PATH command. If it has changed, post back to let us know the new value.

If it is unchanged, you can put that .plist back and restart Terminal again. Now you need to check the other files that bash reads on startup. After /etc/profile, it looks for, and executes the first one that exists, out of ~/.bash_profile, ~/.bash_login, and ~/.profile in that order. You should also check for ~/.bashrc, since this is run for a second and subsequent Terminal window, and is often sourced from one of the others.

You need to look for a line that says

export PATH=".:/usr/local/bin"

and change that to

export PATH="$PATH:/usr/local/bin/."

where I have added '.' as the last item in the path (safest place for it) but would urge you to leave that out.

Jun 14, 2007 7:26 PM in response to Michael Conniff

Thanks.

Before I tried to do any of the things you suggested I tried running the scripts again. This time I got the following error messages:

Peter-Robertsons-Computer:~ peterrobertson$ /usr/bin/sudo /usr/sbin/periodic daily
/usr/sbin/periodic: line 1: hostname: command not found
/usr/sbin/periodic: line 1: mktemp: command not found
/usr/sbin/periodic: line 73: date: command not found
/usr/sbin/periodic: line 1: cat: command not found
/usr/sbin/periodic: line 85: $tmp_output: ambiguous redirect
/usr/sbin/periodic: line 94: cat: command not found
/usr/sbin/periodic: line 96: cp: command not found
/usr/sbin/periodic: line 85: $tmp_output: ambiguous redirect
/usr/sbin/periodic: line 94: cat: command not found
/usr/sbin/periodic: line 96: cp: command not found
/usr/sbin/periodic: line 107: rm: command not found
Peter-Robertsons-Computer:~ peterrobertson$

Does this mean anything different than what you previously described?

Jun 15, 2007 9:38 PM in response to TildeBee

Hi ~bee

It was the Kung Fu reference of the Master's gentle chide to the novice. Always a student, to those with greater knowledge I give respect, though Peter did not know he was being helped by a master.
In addition to knowledge, the second great quality is compassion, and on a yellow sticky at the back of my mind, you ~bee san are noted for a warm heart, and to that I give respect also.
In seeking to wed the two, one soars heavenly toward knowledge whilst one's forehead is smeared with the dust of humility.

Kung Fu and zen!

regards roam

running MAC OS X maintenance scripts manually in terminal mode

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.