how to delay shutdown?

Hi I’m trying to experiment with Applescript but are an absolute beginner so I ask your help.
The first simple attempt is to set shutdown don a minute late.
To be clear: I would like to turn the computer off after thirty seconds to do that the shutdown command, what is the correct syntax?

Thanks a lot.

You may try :


delay 30 # 30 seconds
tell application "System Events"
	shut down
end tell

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 1 février 2016 11:45:33

Thanks!!!

I tried but it seems that the delay does not work, turn off your computer immediately :frowning:

Which operating system are you running ?
If I remember well, delay didn’t worked well with 10.10.x
When an asker doesn’t tell which is the OS running, I assume that he is running the late version.

Under 10.10.x, some users were forced to replace
delay 30
by
do shell script “sleep 30”

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 1 février 2016 12:28:33

You’re right, I have not specified why I did not think it was important, I’m sorry.

I am on OS X 10.10.5

While you answered I edited my own message with :
do shell script “sleep 30”

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 1 février 2016 12:35:00

So it must be

do shell script "sleep 30" # 30 seconds
tell application "System Events"
   shut down
end tell

right?

Exactly.

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 1 février 2016 15:31:09