#!/usr/bin/perl -w use strict; my $run_crontab = 1; my @safe_argv; my ( $bForce, $bRemove, $bHelp ); foreach ( @ARGV ) { if ( uc( $_ ) eq '--FORCE' ) { $bForce = 1; } else { if ( uc( $_ ) eq '-R' ) { $bRemove = 1; } push( @safe_argv, $_ ); } } if ( $bRemove ) { unless( $bForce ) { my ( $y_or_n ); do { print 'Are you sure you want to remove the crontab? (Y/N): + '; $y_or_n = uc( getc() ); print \"\n\"; } until ( ( $y_or_n eq 'Y' ) || ( $y_or_n eq 'N' ) ); if ( $y_or_n eq 'N' ) { print \"/usr/bin/crontab: no changes made to crontab\n\"; $run_crontab = 0; } } } if ( $run_crontab ) { if ( system( '/usr/bin/crontab', @safe_argv ) == 256 ) { print \"\t--force (delete crontab without prompting)\n\"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: safe cron
by davidrw (Prior) on Jun 14, 2005 at 14:08 UTC | |
by mincus (Chaplain) on Jun 14, 2005 at 14:18 UTC | |
by cog (Parson) on Jun 14, 2005 at 14:13 UTC | |
|
Re: safe cron
by kelan (Deacon) on Jun 15, 2005 at 13:13 UTC |