본문 바로가기
OS/리눅스

crontab

by 헬로웬디 2025. 2. 24.

https://hellowendy.tistory.com/manage/newpost/?type=post&returnURL=%2Fmanage%2Fposts%2F

crontab 디버깅 하기

 

stdout와 stderr를 파일로 리디렉션할 수 있습니다. 출력 캡처에 대한 정확한 문법은 cron이 사용하는 쉘에 따라 다를 수 있습니다. 다음은 모든 출력을 /tmp/mycommand.log 파일에 저장하는 두 가지 예입니다.

 

1 2 * * * /path/to/your/command &>/tmp/mycommand.log
1 2 * * * /path/to/your/command >/tmp/mycommand.log 2>&1

 

 

* * * * * /bin/bash /path/to/your/script.sh

 

# Path to promon.exe
$promonPath = "C:\path\to\promon.exe"

# Path to backup directory
$backupPath = "C:\Backup\"

# Run promon.exe
Start-Process -FilePath $promonPath

# Wait for the process to complete (optional, if promon.exe needs to finish before deleting backup)
# Uncomment the next line if promon.exe runs for a while
# Wait-Process -Name "promon"

# Delete backup files older than a certain number of days (e.g., 7 days)
$daysToKeep = 7
$cutoffDate = (Get-Date).AddDays(-$daysToKeep)

# Find and remove files older than $cutoffDate
Get-ChildItem -Path $backupPath -File | Where-Object { $_.LastWriteTime -lt $cutoffDate } | Remove-Item -Force

Write-Output "Backup files older than $daysToKeep days have been deleted."

'OS > 리눅스' 카테고리의 다른 글

Apache2의 SSL 구성  (0) 2025.01.19
timeserver  (0) 2025.01.10
USER ID 및 GROUP ID 변경하는 방법  (0) 2024.09.24
[Rocky] sudo-enabled 사용자 생성하기  (0) 2024.09.15