- Тайм-аут команды в Mac OS X?
- ОТВЕТЫ
- Ответ 1
- Ответ 2
- timeout.sh
- timeout.sh
- Ответ 3
- Ответ 4
- Ответ 5
- How to check TCP timeout in linux / macos?
- 4 Answers 4
- Using The Terminal Command to Shutdown, Restart and Sleep My Mac?
- 4 Answers 4
- Timeout command on Mac OS X?
- Question or issue on macOS:
- How to solve this problem?
- Solution no. 1:
- Solution no. 2:
- Solution no. 3:
- Solution no. 4:
- Solution no. 5:
- Перезагрузка компьютеров с помощью Терминала на Mac
- Перезагрузка локального компьютера
- Немедленная перезагрузка удаленного компьютера
- Перезагрузка удаленного компьютера в определенное время
- Автоматическая перезагрузка при сбое питания
Тайм-аут команды в Mac OS X?
Есть ли альтернатива для команды тайм-аута в Mac OSx. Основное требование — я могу запустить команду в течение определенного времени.
Эта программа запускает ping в течение 10 секунд в Linux.
ОТВЕТЫ
Ответ 1
Вы можете использовать
И тогда, когда вам нужен тайм-аут, используйте
.. вместо этого. Чтобы объяснить, почему здесь фрагмент из раздела «Оговорки Homebrew»:
Все команды установлены с префиксом «g».
Если вам действительно нужно использовать эти команды с их обычными именами, вы может добавить каталог «gnubin» в ваш PATH из вашего bashrc, например:
Кроме того, вы можете получить доступ к своим справочным страницам с обычными именами, если добавить каталог «gnuman» для вашего MANPATH из вашего bashrc:
Ответ 2
Другой простой подход, который работает в значительной степени кросс-платформенный (потому что он использует Perl, который почти везде), это:
Вместо того, чтобы помещать это в функцию, вы можете просто вставить следующую строку в скрипт, и это тоже будет работать:
timeout.sh
или версия со встроенной справкой/примерами:
timeout.sh
Ответ 3
Вы можете ограничить время выполнения любой программы, используя следующую команду:
Ответ 4
Пакет Timeout из Ubuntu/Debian можно сделать для компиляции на Mac, и он работает. Пакет доступен в http://packages.ubuntu.com/lucid/timeout
Ответ 5
Вы можете сделать ping -t 10 google.com >nul
> nul избавляется от вывода. Таким образом, вместо того, чтобы показывать 64 БАЙТА ИЗ 123.45.67.8 БЛА БЛА БЛА БЛА, он будет просто показывать пустой символ новой строки, пока не истечет время ожидания. Флаг -t можно изменить на любой номер.
Источник
How to check TCP timeout in linux / macos?
I have a network problem on my MacOS that i need to troubleshoot. I know that TCP socket has internal timeout that will close connection if remote party is not responding (but no graceful disconnect either). Is it any command/tool i can use to check exact value of this timeout(s)?
4 Answers 4
You can see all system-set tcp values with
Interpreted from tcp_var.h, tcp_subr.c, and tcp_timer.c:
- net.inet.tcp.keepidle = keepalive idle timer
- net.inet.tcp.keepintvl = interval to send keepalives
- net.inet.tcp.keepinit = timeout for establishing syn
- net.inet.tcp.mssdflt = Default TCP Maximum Segment Size
- net.inet.tcp.v6mssdflt = Default TCP Maximum Segment Size for IPv6
- net.inet.tcp.minmss = Minmum TCP Maximum Segment Size
- net.inet.tcp.minmssoverload = Number of TCP Segments per Second allowed to be under the MINMSS Size
- net.inet.tcp.rfc1323 = Enable rfc1323 (high performance TCP) extensions
- net.inet.tcp.rfc1644 = Enable rfc1644 (TTCP) extensions
- net.inet.tcp.do_tcpdrain = Enable tcp_drain routine for extra help when low on mbufs
- net.inet.tcp.pcbcount = Number of active PCBs
- net.inet.tcp.icmp_may_rst = Certain ICMP unreachable messages may abort connections in SYN_SENT
- net.inet.tcp.strict_rfc1948 = Determines if RFC1948 is followed exactly
- net.inet.tcp.isn_reseed_interval = Seconds between reseeding of ISN secret
- net.inet.tcp.background_io_enabled = Background IO Enabled
- net.inet.tcp.rtt_min = min rtt value allowed
- net.inet.tcp.randomize_ports = Randomize TCP port numbers
- net.inet.tcp.tcbhashsize = Size of TCP control-block hashtable
- net.inet.tcp.msl = Maximum segment lifetime
- net.inet.tcp.always_keepalive = Assume SO_KEEPALIVE on all TCP connections
- net.inet.tcp.broken_peer_syn_rxmit_thres = Number of retransmitted SYNs before TCP disables rfc1323 and rfc1644 during the rest of attempts
- net.inet.tcp.pmtud_blackhole_detection = Path MTU Discovery Black Hole Detection
- net.inet.tcp.pmtud_blackhole_mss = Path MTU Discovery Black Hole Detection lowered MSS
I believe by default 8 keepalives will be sent before the connection is closed if SO_KEEPALIVE is set. Times are in milliseconds.
Источник
Using The Terminal Command to Shutdown, Restart and Sleep My Mac?
I’m getting more interested in using Terminal as an alternative way to address solutions on my Mac. I have seen this question entitled «Is there a better way to shutdown/restart OSX?».
I would therefore like to know:
How to shut down, restart and sleep my Mac using the Terminal command exclusively ?
4 Answers 4
The command you are after is shutdown. This informs all users that the machine is going to be shutdown and tells all apps to close files etc.
The command takes a parameter -h , -r or -s to shut down, restart or sleep the Mac.
The command has to be run as root so you need to use sudo .
e.g. to reboot the machine immediately
e.g. to shutdown the machine in 60 minutes
From comments there are two things to be addressed
How shutdown works is by sending a sigterm to all processes which should then deal with that e.g. save open files etc. If they don’t exit then they will get sent a SIGKILL which forces them to die with no chance to respond. The signals are not sent via the normal key message queue so Apps have to deal with this separately to the code that gets called from quit on the menu. A good app should call common code from both.
This other answer shows how to shutdown as if you hit the menu options. But note that apps can cancel this shutdown
Shut down without showing a confirmation dialog:
Shut down after showing a confirmation dialog:
Restart without showing a confirmation dialog:
Restart after showing a confirmation dialog:
Log out without showing a confirmation dialog:
Log out after showing a confirmation dialog:
Go to sleep ( pmset ):
Go to sleep (AppleScript):
Put displays to sleep (10.9 and later):
The four letter codes for the Apple events are listed in AERegistry.h .
All System Events commands above send Apple events to the loginwindow process. loginwindow is sent the same Apple events as above when you log out, restart, shut down, or put the the Mac to sleep normally. See Technical Q&A QA1134: Programmatically causing restart, shutdown and/or logout.
According to man shutdown , shutdown -h now and shutdown -r now send processes a TERM signal followed by a KILL signal.
According to the Daemons and Services Programming Guide, when you tell loginwindow to log out, processes that support sudden termination are sent a KILL signal, and processes that don’t support sudden termination are terminated in different ways: Cocoa applications receive the applicationShouldTerminate: delegate method, foreground applications receive the kAEQuitApplication Apple event, background applications receive the kAEQuitApplication Apple event followed by a KILL signal, and daemons receive a TERM signal followed by a KILL signal after a few seconds.
Источник
Timeout command on Mac OS X?
Question or issue on macOS:
Is there an alternative for the timeout command on Mac OSx. The basic requirement is I am able to run a command for a specified amount of time.
This program runs ping for 10s on Linux.
How to solve this problem?
Solution no. 1:
And then whenever you need timeout, use
..instead. To explain why here’s a snippet from the Homebrew Caveats section:
Caveats
All commands have been installed with the prefix ‘g’.
If you really need to use these commands with their normal names, you
can add a “gnubin” directory to your PATH from your bashrc like:
PATH=”/usr/local/opt/coreutils/libexec/gnubin:$PATH”
Additionally, you can access their man pages with normal names if you add
the “gnuman” directory to your MANPATH from your bashrc as well:
MANPATH=”/usr/local/opt/coreutils/libexec/gnuman:$MANPATH”
Solution no. 2:
Another simple approach that works pretty much cross platform (because it uses perl which is nearly everywhere) is this:
Instead of putting it in a function, you can just put the following line in a script, and it’ll work too:
timeout.sh
or a version that has built in help/examples:
timeout.sh
Solution no. 3:
You can limit execution time of any program using this command:
Solution no. 4:
The Timeout Package from Ubuntu / Debian can be made to compile on Mac and it works.
The package is available at http://packages.ubuntu.com/lucid/timeout
Solution no. 5:
You can do ping -t 10 google.com >nul
the >nul gets rid of the output. So instead of showing 64 BYTES FROM 123.45.67.8 BLAH BLAH BLAH it’ll just show a blank newline until it times out. -t flag can be changed to any number.
Источник
Перезагрузка компьютеров с помощью Терминала на Mac
Чтобы перезагрузить компьютер немедленно или в определенное время с помощью приложения «Терминал», используйте команду shutdown или systemsetup . В следующих примерах показано несколько способов использования этих команд. Полная информация о них приведена на man-странице команды shutdown и man-странице команды systemsetup.
Совет. Можно легко перезагрузить Mac, выбрав меню «Apple»
> «Перезагрузить», или выключить компьютер, выбрав меню «Apple» > «Выключить». См. раздел Выход из системы, переход в режим сна, перезагрузка и выключение Mac.
Перезагрузка локального компьютера
В приложении «Терминал» на Mac введите следующую команду:
Немедленная перезагрузка удаленного компьютера
В приложении «Терминал» на Mac введите следующие команды:
Вместо admin укажите короткое имя учетной записи пользователя на удаленном компьютере.
Вместо computer укажите IP-адрес или имя хоста удаленного компьютера.
Перезагрузка удаленного компьютера в определенное время
В приложении «Терминал» на Mac введите следующие команды:
Вместо admin укажите короткое имя учетной записи пользователя на удаленном компьютере.
Вместо computer укажите IP-адрес или имя хоста удаленного компьютера.
Вместо hhmm укажите время перезагрузки удаленного компьютера (в формате ччмм).
Автоматическая перезагрузка при сбое питания
В приложении «Терминал» на Mac введите следующую команду:
Вместо seconds укажите количество секунд, по прошествии которых компьютер должен загружаться после сбоя питания. Значение должно быть равно 0 (нуль) или быть кратно 30.
Примечание. Можно также задать настройки энергосбережения, чтобы компьютер Mac автоматически перезагружался после сбоя питания.
Источник