Linux: July 2012 Archives

Get Linux uptime seconds

user-pic
Vote 0 Votes

cat /proc/uptime
35115009.84 28744638.57

第一個數字是開機秒數
第二個數字是 Idle 秒數

若 crontab 裡要設條開機後一個小時才執行某動作, 可以這樣設定
[ `cut -d. -f1 /proc/uptime` -gt 3600 ] && some-script

ref. /proc/uptime

PHP Web Server

user-pic
Vote 0 Votes

PHP 5.4.0 開始, PHP CLI 內建 Web Server

php -S 0.0.0.0:80
會以目前的目錄為 Document root

If Linux, 把這個 phpwebserver Script 放在 /etc/init.d
chkconfig phpwebserver on

修改一下 Script 前面的參數符合需求
PHP=/usr/local/bin/php
LOG=/var/log/phpwebserver.log
PORT=80
DOCUMENT_ROOT=/var/www/html

service phpwebserver start 即可啟動
index 檔搜尋的順序為 index.php index.html

拿來測試或小型網站使用應該很足夠

ref. PHP: Built-in web server

About this Archive

This page is an archive of entries in the Linux category from July 2012.

Linux: June 2012 is the previous archive.

Linux: August 2012 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives