PowerShell/demos/crontab/crontab.ps1

22 lines
551 B
PowerShell
Raw Normal View History

2016-07-20 22:49:44 +02:00
Import-Module $PSScriptRoot/CronTab/CronTab.psd1
# Get the existing cron jobs
2016-07-20 22:49:44 +02:00
Get-CronJob
2016-07-20 22:49:44 +02:00
# New cron job to clean out tmp every day at 1am
New-CronJob -Command 'rm -rf /tmp/*' -Hour 1
2016-07-20 22:49:44 +02:00
# New cron job to start a build
New-CronJob -Command 'powershell -c "cd ~/src/PowerShell; ipmo ./build.psm1; Start-PSBuild"' -Hour 2 -DayOfWeek 1-5
# Sort them by data
Get-CronJob | Sort-Object Command
# Show in bash that the new cron job exists
2016-07-20 22:49:44 +02:00
crontab -l
# Remove a cron job
Get-CronJob | Where-Object { $_.Command -match '^powershell.*' } | Remove-CronJob