Updated script to tag demo jobs and clean up afterwards; removed line that removes all jobs from start (#1783)

This commit is contained in:
Steve Lee 2016-08-12 17:41:56 -07:00 committed by Jason Shirk
parent 7cf93ba966
commit 9c119e2781

View File

@ -1,18 +1,15 @@
Import-Module $PSScriptRoot/CronTab/CronTab.psd1
Write-Host -Foreground Yellow "Remove all jobs to start, no prompting"
Get-CronJob | Remove-CronJob -Force
Write-Host -Foreground Yellow "Get the existing cron jobs"
Get-CronJob | Out-Host
Write-Host -Foreground Yellow "New cron job to clean out tmp every day at 1am"
New-CronJob -Command 'rm -rf /tmp/*' -Hour 1 | Out-Host
New-CronJob -Command 'rm -rf /tmp/*; #demo' -Hour 1 | Out-Host
Write-Host -Foreground Yellow "Add some more jobs"
New-CronJob -Command 'python -c ~/scripts/backup_users' -Hour 2 -DayOfWeek 1-5 | Out-Host
New-CronJob -Command 'powershell -c "cd ~/src/PowerShell; ipmo ./build.psm1; Start-PSBuild"' -Hour 2 -DayOfWeek * | Out-Host
New-CronJob -Command 'python -c ~/scripts/backup_users; #demo' -Hour 2 -DayOfWeek 1-5 | Out-Host
New-CronJob -Command 'powershell -c "cd ~/src/PowerShell; ipmo ./build.psm1; Start-PSBuild"; #demo' -Hour 2 -DayOfWeek * | Out-Host
Write-Host -Foreground Yellow "Show in bash that the new cron job exists"
crontab -l
@ -25,3 +22,9 @@ Get-CronJob | Where-Object { $_.Command -match '^powershell.*' } | Remove-CronJo
Write-Host -Foreground Yellow "And the other job remains"
Get-CronJob | Out-Host
Write-Host -Foreground Yellow "Remove remaining demo jobs without prompting"
Get-CronJob | Where-Object { $_.Command -match '#demo'} | Remove-CronJob -Force
Write-Host -Foreground Yellow "Show in bash that cron should be clean"
crontab -l