#554, 实现挂载目录的定时移除,每月运行一次,清除之前4个月到3个月之间的目录挂载
This commit is contained in:
parent
f31402c7be
commit
fcf96d5973
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
$link = pg_connect("dbname=metadata user=gis password=gispassword host=210.77.68.241");
|
||||||
|
if (!$link)
|
||||||
|
{
|
||||||
|
die("Error in connection: " . pg_last_error());
|
||||||
|
}
|
||||||
|
$sql="select dataorder.userid,dataset.path from dataorder left join dataset on dataorder.uuid=dataset.uuid
|
||||||
|
where dataorder.status in (0,5) and dataset.host='ftp2.westgis.ac.cn' and dataset.path<>''
|
||||||
|
and dataorder.ts_approved<now()-interval '3 months'
|
||||||
|
and dataorder.ts_approved>=now()-interval '4 months'
|
||||||
|
and dataorder.selection is null";
|
||||||
|
$result = pg_query($link, $sql);
|
||||||
|
$numrows = pg_num_rows($result);
|
||||||
|
|
||||||
|
$content='';
|
||||||
|
for($ri = 0; $ri < $numrows; $ri++)
|
||||||
|
{
|
||||||
|
$row = pg_fetch_array($result, $ri);
|
||||||
|
$content.='# path: '.$row['path']."\n";
|
||||||
|
$content.='umount "/home/ftp/westdc_'.$row['userid'].'/'.preg_replace('/^.+[\\\\\\/]/', '', rtrim($row['path'],'/')).'"'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename='./ftp-umount.sh';
|
||||||
|
if (!empty($content))
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
die("error in write proftp-user.sh");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pg_free_result($result);
|
||||||
|
pg_close($link);
|
||||||
|
?>
|
Loading…
Reference in New Issue