查看完整版本: Cpanel ─ Cron Jobs使用教學

rengo 2005-10-6 21:35

Cpanel ─ Cron Jobs使用教學

[color=blue][size=3]Cpanel ─ Cron Jobs使用教學(-)[/size][/color]
[img]http://webs.hk/dead/deadlink.gif[/img]
進入cPanel Cron Jobs依照您的習慣選Standard或Advanced(Unix style)
[img]http://webs.hk/dead/deadlink.gif[/img]
設定自己需要的執行備份時間,
command輸入
[size=2]CODE:[/size][/b]  [url=http://webs.hk/bbs/viewthread.php?tid=163&fpage=1###][color=#003366][size=2][Copy to clipboard][/size][/color][/url]
/usr/local/bin/php/home/account/fullbackup.php
[img]http://webs.hk/dead/deadlink.gif[/img]
/home/acount/fullbackup.php
是假設您的主目錄為/home/account/
而fullbackup.php放在主目錄下,
如果不是請自行更改為您的設定.
fullbackup.php已經有提供訊息通知,
cron job的信件通知可以不填.
[color=red]注意[/color]:
請將fullbackup.php設定為600,
並且不要放在public_html資料夾下,
檔案包含使用者帳號密碼,
您將自己承擔使用風險.
[img]http://webs.hk/dead/deadlink.gif[/img]
以下內容儲存為fullbackup.php
[code]<?php

// 此PHP程式將定期自動產生cPanel備份,
// 以max.hedroom在cpanel.net論壇的文章為程式基礎,
// 這個程式包含密碼, 請注意檔案安全.
// 中文翻譯: Max, [email]max@max.idv.tw[/email]

// ********* 下列項目需要設定 *********

// cPanel登入資訊
$cpuser = "username"; // 登入cPanel的帳號
$cppass = "password"; // 登入cPanel的密碼
$domain = "example.com"; // cPanel使用的網域
$skin = "x"; // 設定正在使用的cPanel樣版(例如 rvblue)

// FTP上傳的資訊
$ftpuser = "ftpusername"; // FTP帳號
$ftppass = "ftppassword"; // FTP密碼
$ftphost = "ftp.example.com"; // FTP伺服器網址(或ip)
$ftpmode = "ftp"; // FTP模式("ftp"或"passiveftp")

// 通知資訊
$notifyemail = "[email]you@example.com[/email]"; // 寄發執行結果的e-mail位置

// 安全模式
$secure = 0; // 0為標準http, 1為ssl(需要主機支援ssl功能)

// 設定值為1時會在排程記錄中產生網頁報告
$debug = 0;

// *********** 以下不需更改 *********

if ($secure) {
$url = "ssl://".$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}

$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection… Bailing out!n"; exit; }

// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);

$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&submit=Generate Backup";

// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0rn");
fputs($socket,"Host: $domainrn");
fputs($socket,"Authorization: Basic $passrn");
fputs($socket,"Connection: Closern");
fputs($socket,"rn");

// Grab response even if we don’t do anything with it.
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}

fclose($socket);

?>[/code]

其中$skin的設定,請留意你空間所提供的樣版
你可以用[url=http://yourdomain.com:2082/][color=#003366]http://yourdomain.com:2082[/color][/url] ,登入後
出現 [url=http://our-host.info:2082/frontend/x/][color=#003366]http://our-host.info:2082/frontend/x/[/color][/url]
x就是該cpanel的樣版
製作:踏雪無痕
頁: [1]
查看完整版本: Cpanel ─ Cron Jobs使用教學