Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
centos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
platyhouse
centos
Commits
9274d990
Commit
9274d990
authored
Jan 15, 2025
by
platyhouse
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3560818d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
195 additions
and
0 deletions
+195
-0
install_path.sh
install_path.sh
+1
-0
pty_archive.php
pty_archive.php
+63
-0
pty_check_folder_last_time.php
pty_check_folder_last_time.php
+75
-0
pty_check_unused.php
pty_check_unused.php
+55
-0
pty_get_folder_last_time.php
pty_get_folder_last_time.php
+1
-0
No files found.
install_path.sh
0 → 100755
View file @
9274d990
grep
-Fxq
'export PATH=$PATH:/root/pty_centos.git'
/etc/bashrc
||
echo
'export PATH=$PATH:/root/pty_centos.git'
>>
/etc/bashrc
pty_archive.php
0 → 100644
View file @
9274d990
<?php
// CLI로 실행해야 하므로 PHP SAPI 확인
if
(
php_sapi_name
()
!==
'cli'
)
{
exit
(
"이 스크립트는 CLI에서만 실행 가능합니다.
\n
"
);
}
// 사용자로부터 인자 입력받기
if
(
$argc
<
2
)
{
exit
(
"사용법: php backup.php [database_name]
\n
"
);
}
$date
=
date
(
"Ymd_His"
);
$databaseName
=
$argv
[
1
];
$backupDir
=
"
$databaseName
"
;
$dumpFile
=
"
$databaseName
/
{
$databaseName
}
_
{
$date
}
.sql"
;
$zipFile
=
__DIR__
.
"/
{
$databaseName
}
_
{
$date
}
.tgz"
;
// MySQL 설정 (환경에 맞게 수정)
$mysqlHost
=
'localhost'
;
$mysqlUser
=
'root'
;
$mysqlPassword
=
'Tmxhfl!!00'
;
// 디렉터리 생성
if
(
!
is_dir
(
$backupDir
))
{
mkdir
(
$backupDir
,
0755
,
true
);
}
// MySQL 덤프 실행
echo
"MySQL 덤프 생성 중...
\n
"
;
$dumpCommand
=
sprintf
(
'mysqldump -h%s -u%s -p%s %s > %s'
,
escapeshellarg
(
$mysqlHost
),
escapeshellarg
(
$mysqlUser
),
escapeshellarg
(
$mysqlPassword
),
escapeshellarg
(
$databaseName
),
escapeshellarg
(
$dumpFile
)
);
exec
(
$dumpCommand
,
$output
,
$resultCode
);
if
(
$resultCode
!==
0
)
{
exit
(
"MySQL 덤프 실패:
$dumpCommand
\n
"
);
}
echo
"MySQL 덤프 생성 완료:
$dumpFile
\n
"
;
// 폴더 압축
echo
"폴더 압축 중...
\n
"
;
$zipCommand
=
sprintf
(
'tar cvzf %s %s'
,
escapeshellarg
(
$zipFile
),
escapeshellarg
(
$backupDir
)
);
exec
(
$zipCommand
,
$output
,
$resultCode
);
if
(
$resultCode
!==
0
)
{
exit
(
"폴더 압축 실패:
$zipCommand
\n
"
);
}
echo
"폴더 압축 완료:
$zipFile
\n
"
;
// 결과 출력
echo
"백업 완료!
\n
"
;
echo
"SQL 덤프 파일:
$dumpFile
\n
"
;
echo
"압축 파일:
$zipFile
\n
"
;
pty_check_folder_last_time.php
0 → 100755
View file @
9274d990
<?php
// CLI에서 폴더 경로 입력 받기
$folderPath
=
isset
(
$argv
[
1
])
?
$argv
[
1
]
:
""
;
if
(
$folderPath
===
""
)
{
// 현재 디렉토리 설정
$folderPath
=
getcwd
();
}
if
(
!
is_dir
(
$folderPath
))
{
die
(
"입력한 경로가 유효한 폴더가 아닙니다.
\n
"
);
}
// 현재 폴더의 하위 폴더 목록 가져오기
$folders
=
array_filter
(
glob
(
$folderPath
.
DIRECTORY_SEPARATOR
.
'*'
),
'is_dir'
);
if
(
empty
(
$folders
))
{
die
(
"현재 디렉토리에 하위 폴더가 없습니다.
\n
"
);
}
$folderData
=
[];
// 각 폴더의 데이터를 저장할 배열
// 각 폴더의 최신 파일 날짜 계산
foreach
(
$folders
as
$folder
)
{
$iterator
=
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$folder
,
RecursiveDirectoryIterator
::
SKIP_DOTS
)
);
$latestTimestamp
=
0
;
// 각 폴더의 최신 날짜 저장
$latestFilePath
=
""
;
// 최신 파일의 경로 저장
foreach
(
$iterator
as
$file
)
{
if
(
$file
->
isFile
())
{
$fileCreationTime
=
filectime
(
$file
->
getPathname
());
if
(
$fileCreationTime
>
$latestTimestamp
)
{
$latestTimestamp
=
$fileCreationTime
;
$latestFilePath
=
$file
->
getPathname
();
}
}
}
$folderName
=
basename
(
$folder
);
$folderData
[]
=
[
'folderName'
=>
$folderName
,
'latestTimestamp'
=>
$latestTimestamp
,
'latestFilePath'
=>
$latestFilePath
?:
"No files"
];
}
// 최신 파일 날짜 기준으로 정렬 (오래된 것이 아래로)
usort
(
$folderData
,
function
(
$a
,
$b
)
{
if
(
$a
[
'latestTimestamp'
]
==
$b
[
'latestTimestamp'
])
{
return
0
;
}
return
(
$a
[
'latestTimestamp'
]
>
$b
[
'latestTimestamp'
])
?
-
1
:
1
;
// 최신 파일 날짜가 오래된 것이 아래로
});
// 결과 출력
echo
str_repeat
(
"="
,
120
)
.
"
\n
"
;
printf
(
"| %-30s | %-20s | %-40s |
\n
"
,
"Folder Name"
,
"Latest File Date"
,
"File Path"
);
echo
str_repeat
(
"="
,
120
)
.
"
\n
"
;
foreach
(
$folderData
as
$data
)
{
$latestDate
=
$data
[
'latestTimestamp'
]
>
0
?
date
(
"Y-m-d H:i:s"
,
$data
[
'latestTimestamp'
])
:
"N/A"
;
printf
(
"| %-30s | %-20s | %-40s |
\n
"
,
$data
[
'folderName'
],
$latestDate
,
$data
[
'latestFilePath'
]
);
}
echo
str_repeat
(
"="
,
120
)
.
"
\n
"
;
pty_check_unused.php
0 → 100644
View file @
9274d990
<?php
// MySQL 연결 설정
$host
=
'localhost'
;
$user
=
'root'
;
$password
=
'Tmxhfl!!00'
;
// 6개월 전 날짜 계산
$sixMonthsAgo
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
'-6 months'
));
// MySQL 연결
$conn
=
new
mysqli
(
$host
,
$user
,
$password
);
if
(
$conn
->
connect_error
)
{
die
(
"MySQL 연결 실패: "
.
$conn
->
connect_error
.
"
\n
"
);
}
// 쿼리 실행
$query
=
"
SELECT table_schema AS database_name, MAX(update_time) AS last_used
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys')
GROUP BY table_schema
# HAVING MAX(update_time) < '
$sixMonthsAgo
' OR MAX(update_time) IS NULL
ORDER BY last_used DESC;
"
;
$result
=
$conn
->
query
(
$query
);
if
(
!
$result
)
{
die
(
"쿼리 실행 실패: "
.
$conn
->
error
.
"
\n
"
);
}
// 결과 출력
echo
str_repeat
(
"="
,
80
)
.
"
\n
"
;
printf
(
"| %-30s | %-20s | %-15s |
\n
"
,
"Database Name"
,
"Last Used"
,
"Days Since"
);
echo
str_repeat
(
"="
,
80
)
.
"
\n
"
;
while
(
$row
=
$result
->
fetch_assoc
())
{
$databaseName
=
$row
[
'database_name'
];
$lastUsed
=
isset
(
$row
[
'last_used'
])
?
$row
[
'last_used'
]
:
'Never used'
;
if
(
$lastUsed
!==
'Never used'
)
{
$daysElapsed
=
floor
((
time
()
-
strtotime
(
$lastUsed
))
/
(
60
*
60
*
24
));
printf
(
"| %-30s | %-20s | %-15s |
\n
"
,
$databaseName
,
$lastUsed
,
"
$daysElapsed
days"
);
}
else
{
printf
(
"| %-30s | %-20s | %-15s |
\n
"
,
$databaseName
,
"Never used"
,
"N/A"
);
}
}
echo
str_repeat
(
"="
,
80
)
.
"
\n
"
;
// MySQL 연결 종료
$conn
->
close
();
pty_get_folder_last_time.php
View file @
9274d990
#!/usr/bin/php
<?php
$rootDir
=
$argv
[
1
];
...
...
platyhouse
@platyhouse
mentioned in commit
8587004b
·
Dec 16, 2025
mentioned in commit
8587004b
mentioned in commit 8587004bfbebb2ceff13804bc1eea04727f6a285
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment