PowerShell/demos/crontab/crontab.ps1
Jason Shirk 3dafae5357 Move crontab demo to it's own directory
Also change CronTab.psd1 encoding to ASCII
2016-07-21 08:51:09 -07:00

22 lines
551 B
PowerShell

Import-Module $PSScriptRoot/CronTab/CronTab.psd1
# Get the existing cron jobs
Get-CronJob
# New cron job to clean out tmp every day at 1am
New-CronJob -Command 'rm -rf /tmp/*' -Hour 1
# 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
crontab -l
# Remove a cron job
Get-CronJob | Where-Object { $_.Command -match '^powershell.*' } | Remove-CronJob