EE2 Forums 및 EE1 Forums에는 cron 작업을 다양한 용도로 사용하는 사람들이 많이 있습니다.
#!usr/local/bin/php -n
<?php global $PREFS; // ee_cli_sql.php v0.3.5
/* Copyright (c) 2003 - 2007 EllisLab, Inc. --- ExpressionEngine 1.6.0.
Some code by Ingmar Greil, 2007. <[email protected]>
My modfications and code released under a Creative Commons
"Attribution" license: http://creativecommons.org/licenses/by/2.0/
This PHP command line script allows you to perform arbitrary
SQL queries on your EE database. There will be no visible output
(in this case we'd simply use the Query module in a template, right?),
since the whole point is to run this script unattended.
Put this file in your EE "system" folder, make sure the executable
bit is set (chmod +x ee_cli_sql.php), then call manually or via cron.
Try "crontab -e".
"5 * * * * command" will run your script 5 minutes past the hour, every hour.
"0,10,20,30,40,50 6-22 * * * 1-5" will run your script every ten minutes
between 6am and 10pm, except on weekends. The general syntax is:
<Minute> <Hour> <Day> <Month> <Day of Week> <Command line>
*/
// This query will set all expired entries to "closed" status:
$query = "UPDATE `exp_weblog_titles` SET status = 'closed' WHERE status <> 'closed'
AND expiration_date <> '0' AND expiration_date < UNIX_TIMESTAMP()";
// Change the above query to suit your needs.
// That's it, folks! No user-serviceable parts below.
define("EXT",".php"); // Get around EE's security mechanisms. Kludgy? Hell, yes.
// Got a better solution? I am all ears.
require("config".EXT); // Read the config file
require("core/core.prefs".EXT); // Load the PREFS cass
$PREFS = new Preferences(); $PREFS->core_ini = $conf; unset($conf);
$db = mysql_connect( // Handle the connection to the database:
$PREFS->core_ini['db_hostname'], // hostname,
$PREFS->core_ini['db_username'], // username and
$PREFS->core_ini['db_password']); // password are all pulled automatically.
mysql_select_db($PREFS->core_ini['db_name']); // Now it's selecting the appropriate db,
mysql_query($query,$db); // performing the actual query, then
mysql_close(); // cleaning up after ourselves. Done.
?>
ExpressionEngine 위키 문서에서는 스크립트 설정 및 예약 방법에 몇 가지 통찰력을 제공
:
는
가장 인기있는 사용은 예약 cron 작업으로 명령 줄 PHP 스크립트를 사용하여, automatically closing expired entries 것 같다
이 PHP 명령 행 스크립트를 사용하면 사용자는 EE 데이터베이스에서 임의의 SQL 쿼리 을 수행 할 수 있습니다. 보이는 출력이 없습니다 (이 경우 템플릿에서 검색어 모듈을 사용하면됩니다). 전체 포인트는이 스크립트 을 자동으로 실행하기 때문에 표시됩니다.
이 폴더 당신의 EE "시스템"이 파일을 넣고, 실행 비트 다음 (chmod를 + X ee_cli_sql.php), 전화를 수동으로 또는 cron을 통해이 설정되어 있는지 확인합니다.
당신이 아니라 당신의 cron 작업을 관리하기 위해 CLI (명령 줄 인터페이스)를 사용하지 않으려면 정기적, 일정에 따라 플러그인이나 모듈을 호출하도록 설정 될 수있는, 앨리스 랩에서 Cron Plugin을 고려해 볼 수 있습니다 .
출처
2011-05-26 17:20:44
rjb
만료 된 항목을 자동으로 닫는 링크가 작동하지 않습니다. – williamcarswell
EllisLab이 2012 년 11 월에 사이트를 재 설계했을 때, 그들은 Wiki를 넘지 않았으며 모든 링크는'ellislab.com'으로 리디렉션되었습니다. 다행히도, 나는 [인터넷 아카이브 WayBack Machine] (http : //web.archive.)에서 원래 기사를 발췌 할 수있었습니다.org/web/20120103211342/http : //expressionengine.com/wiki/Automatically_close_expired_entries) – rjb