Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

remove crontab entries

by nmete (Novice)
on Jul 22, 2004 at 20:05 UTC ( [id://376706]=perlquestion: print w/replies, xml ) Need Help??

nmete has asked for the wisdom of the Perl Monks concerning the following question:

I could not find any methods in Schedule::Cron to remove one particular entry.
I don't want to remove all entries, (clean_timetable() does so) but after finishing my scheduled job i want to remove the corresponding job. this means I want to run the scheduled job only once.
In unix 'at' command is used, istead of cron, for this purpose.
In perl, Schedule::At module allows to run some unix commands but seems not supporting subroutine calls.
is there any way to subroutine calls with Schedule::At or is there any way to run each entry once with Schedule::Cron?

Replies are listed 'Best First'.
Re: remove crontab entries
by Plankton (Vicar) on Jul 22, 2004 at 20:39 UTC
    I don't know anything about Schedule::Cron but you could do something like this ...
    $ crontab -l 5 5 * * * touch cron_ran_`date| tr ' :' '_'` 10 10 * * * doSomethingOrOther $ crontab -l | grep -v touch | crontab $ crontab -l 10 10 * * * doSomethingOrOther
    If you need cron to remove the job itself just set up your crontab like this ...
    5 5 * * * touch cron_ran_`date| tr ' :' '_'` && crontab -l | grep -v t +ouch | crontab 10 10 * * * doSomethingOrOther

    Plankton: 1% Evil, 99% Hot Gas.
      Schedule::Cron doesn't use cron - it forks off its own scheduler process therefore touching the crontab file won't affect it. As the poster said there isn't a suitable method to remove an individual job.
Re: remove crontab entries
by Jonathan (Curate) on Jul 23, 2004 at 15:16 UTC
    Sorry, but I don't really understand the problem. Schedule::At looks like (I've never used it) it is process orientated so if you wanted to call a subroutine using it you'll be better off wrapping your subroutine into a process or rolling your own simple scheduler wrapper. For anything more complicated I suggest POE
      To make it more clear:

      To my understandig with Schedule:At I can only run some system commands at a particular time. or I can run some script files.
      But it does not seem sophisticated enough that I can call any function of a script (ie: perl). I need to call function because I need to pass parameters (entered by user via web interface)

      Schedule::Cron does what I actually want. and I have a running code with cron.. but I want to run my scheduled jobs only once. this is the problem with cron.
      so if I say $cron->add_entry("00 10 26 07 *") I want it to run at 10am, 26th of June 2004 but not at the same time of 2005.

      I am not sure if this is the already case.. If so, not problem anymore

      Nurcan
Re: remove crontab entries
by Anonymous Monk on Dec 17, 2012 at 15:42 UTC
    simple $ crontab -e it will enter you into a nano/pico type file find yout crontab remove it save and then see it it works type $ crontab -l

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://376706]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found