Sponsored Content
Top Forums Shell Programming and Scripting Cron Job to Run every 2 minutes Post 302962868 by fpmurphy on Saturday 19th of December 2015 10:11:03 PM
Old 12-19-2015
Something like this (in Linux)
Code:
0/2 11-23 * * *  /path/to/your/script
0/2  0-4  * * *  /path/to/your/script

Your script then needs to contain logic to check the current time and not run to completion if the current time is before 11.25 or after 03.25.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Run cron job problem

I have the below crontab job that it will run at every 7:00am - 10:00am , it work fine , now if I want to skip to run the crontab job at a specific time , eg. I want the script not to run at next Monday 8:00am ( only skip this time , other time is normal ) , how can I make it ? is it possible ?... (3 Replies)
Discussion started by: ust
3 Replies

2. Shell Programming and Scripting

Does not run via cron job

I have a perl script, when I ran manually it works perfect. I check the permissions which are fine. How can I find out why it is not running? how can I setup a log to check. I am running it on solaris 9. It compares multiple files, SCP and then send out an e-mail. As I said when I ran it... (2 Replies)
Discussion started by: amir07
2 Replies

3. UNIX for Advanced & Expert Users

Need help with a script run by a cron job.

Hi, new to this forum and not sure if this is the right place to post. I'm new to cron jobs and scripts, and I need some help with a script to be used with a cron job. I already have a bot set up at a certain website address and need a script that the cron job will load every day that tells it to... (1 Reply)
Discussion started by: klawless
1 Replies

4. Shell Programming and Scripting

Cron job for every five minutes and between hours

Hi I need to run a script every five minutes and it should run between 07-15 hours all days. How i can achieve this... i tried like this */5 07-15 * * * /scripts/CreateFtpData.sh It throws an error... (1 Reply)
Discussion started by: aemunathan
1 Replies

5. Solaris

How to setup a cron job to run every 45 minutes in Solaris 5.10

How to setup a cron job to run every 45 minutes in Solaris 5.10 (9 Replies)
Discussion started by: reyazan
9 Replies

6. UNIX for Advanced & Expert Users

Use cron to run job every other week

my colleague was asking about this: is there a way to run a cron job biweekly, like a script five.sh to run every *OTHER* Friday within November its part about every other Friday we cant find any documentation. thx L (8 Replies)
Discussion started by: lydiaflamp
8 Replies

7. Shell Programming and Scripting

Cron doesn't run job in background

Hi, First of all merry christmas and Happy holidays to all :D My situation is as below, When a backup job runs on a mainframe server, it creates a 0byte file on a network drive which is accessible through linux Linux server : Red Hat Enterprise Linux Server release 5.3 Beta (Tikanga) File... (6 Replies)
Discussion started by: sam05121988
6 Replies

8. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

9. Shell Programming and Scripting

Cron Job to Run for 30 minutes

Hello Gurus, I have a requirement to run a job from cron only for 30 minutes duration daily twice at 8.35 am and 20.35 pm Can you please suggest how to schedule the job? Thanks- Pokhraj (5 Replies)
Discussion started by: pokhraj_d
5 Replies

10. Shell Programming and Scripting

Cron job cannot run the command

Hi, I created this cron job for asterisk to send sms daily to a number #!/bin/sh #custom mod - send sms once a day, at 07:00. CRON_PATH="/etc/asterisk/gw/crontabs_root"; if ! grep 'gsm send sms' $CRON_PATH > /dev/null 2>&1 ;then echo "* 7 * * * asterisk -rx 'gsm send sms 1 7666... (4 Replies)
Discussion started by: jazzyzha
4 Replies
Catalyst::Plugin::Scheduler(3pm)			User Contributed Perl Documentation			  Catalyst::Plugin::Scheduler(3pm)

NAME
Catalyst::Plugin::Scheduler - Schedule events to run in a cron-like fashion SYNOPSIS
use Catalyst qw/Scheduler/; # run remove_sessions in the Cron controller every hour __PACKAGE__->schedule( at => '0 * * * *', event => '/cron/remove_sessions' ); # Run a subroutine at 4:05am every Sunday __PACKAGE__->schedule( at => '5 4 * * sun', event => &do_stuff, ); # A long-running scheduled event that must be triggered # manually by an authorized user __PACKAGE__->schedule( trigger => 'rebuild_search_index', event => '/cron/rebuild_search_index', ); $ wget -q http://www.myapp.com/?schedule_trigger=rebuild_search_index DESCRIPTION
This plugin allows you to schedule events to run at recurring intervals. Events will run during the first request which meets or exceeds the specified time. Depending on the level of traffic to the application, events may or may not run at exactly the correct time, but it should be enough to satisfy many basic scheduling needs. CONFIGURATION
Configuration is optional and is specified in MyApp->config->{scheduler}. logging Set to 1 to enable logging of events as they are executed. This option is enabled by default when running under -Debug mode. Errors are always logged regardless of the value of this option. time_zone The time zone of your system. This will be autodetected where possible, or will default to UTC (GMT). You can override the detection by providing a valid DateTime time zone string, such as 'America/New_York'. state_file The current state of every event is stored in a file. By default this is $APP_HOME/scheduler.state. This file is created on the first request if it does not already exist. yaml_file The location of the optional YAML event configuration file. By default this is $APP_HOME/scheduler.yml. hosts_allow This option specifies IP addresses for trusted users. This option defaults to 127.0.0.1. Multiple addresses can be specified by using an array reference. This option is used for both events where auto_run is set to 0 and for manually-triggered events. __PACKAGE__->config->{scheduler}->{hosts_allow} = '192.168.1.1'; __PACKAGE__->config->{scheduler}->{hosts_allow} = [ '127.0.0.1', '192.168.1.1' ]; SCHEDULING
AUTOMATED EVENTS Events are scheduled by calling the class method "schedule". MyApp->schedule( at => '0 * * * *', event => '/cron/remove_sessions', ); package MyApp::Controller::Cron; sub remove_sessions : Private { my ( $self, $c ) = @_; $c->delete_expired_sessions; } at The time to run an event is specified using crontab(5)-style syntax. 5 0 * * * # 5 minutes after midnight, every day 15 14 1 * * # run at 2:15pm on the first of every month 0 22 * * 1-5 # run at 10 pm on weekdays 5 4 * * sun # run at 4:05am every Sunday From crontab(5): field allowed values ----- -------------- minute 0-59 hour 0-23 day of month 1-31 month 0-12 (or names, see below) day of week 0-7 (0 or 7 is Sun, or use names) Instead of the first five fields, one of seven special strings may appear: string meaning ------ ------- @yearly Run once a year, "0 0 1 1 *". @annually (same as @yearly) @monthly Run once a month, "0 0 1 * *". @weekly Run once a week, "0 0 * * 0". @daily Run once a day, "0 0 * * *". @midnight (same as @daily) @hourly Run once an hour, "0 * * * *". event The event to run at the specified time can be either a Catalyst private action path or a coderef. Both types of event methods will receive the $c object from the current request, but you must not rely on any request-specific information present in $c as it will be from a random user request at or near the event's specified run time. Important: Methods used for events should be marked "Private" so that they can not be executed via the browser. auto_run The auto_run parameter specifies when the event is allowed to be executed. By default this option is set to 1, so the event will be executed during the first request that matches the specified time in "at". If set to 0, the event will only run when a request is made by a user from an authorized address. The purpose of this option is to allow long-running tasks to execute only for certain users. MyApp->schedule( at => '0 0 * * *', event => '/cron/rebuild_search_index', auto_run => 0, ); package MyApp::Controller::Cron; sub rebuild_search_index : Private { my ( $self, $c ) = @_; # rebuild the search index, this may take a long time } Now, the search index will only be rebuilt when a request is made from a user whose IP address matches the list in the "hosts_allow" config option. To run this event, you probably want to ping the app from a cron job. 0 0 * * * wget -q http://www.myapp.com/ MANUAL EVENTS To create an event that does not run on a set schedule and must be manually triggered, you can specify the "trigger" option instead of "at". __PACKAGE__->schedule( trigger => 'send_email', event => '/events/send_email', ); The event may then be triggered by a standard web request from an authorized user. The trigger to run is specified by using a special GET parameter, 'schedule_trigger'; the path requested does not matter. http://www.myapp.com/?schedule_trigger=send_email By default, manual events may only be triggered by requests made from localhost (127.0.0.1). To allow other addresses to run events, use the configuration option "hosts_allow". SCHEDULING USING A YAML FILE
As an alternative to using the schedule() method, you may define scheduled events in an external YAML file. By default, the plugin looks for the existence of a file called "scheduler.yml" in your application's home directory. You can change the filename using the configuration option "yaml_file". Modifications to this file will be re-read once per minute during the normal event checking process. Here's an example YAML configuration file with 4 events. Each event is denoted with a '-' character, followed by the same parameters used by the "schedule" method. Note that coderef events are not supported by the YAML file. --- - at: '* * * * *' event: /cron/delete_sessions - event: /cron/send_email trigger: send_email - at: '@hourly' event: /cron/hourly - at: 0 0 * * * auto_run: 0 event: /cron/rebuild_search_index SECURITY
All events are run inside of an eval container. This protects the user from receiving any error messages or page crashes if an event fails to run properly. All event errors are logged, even if logging is disabled. PLUGIN SUPPORT
Other plugins may register scheduled events if they need to perform periodic maintenance. Plugin authors, be sure to inform your users if you do this! Events should be registered from a plugin's "setup" method. sub setup { my $c = shift; $c->maybe::next::method(@_); if ( $c->can('schedule') ) { $c->schedule( at => '0 * * * *', event => &cleanup, ); } } CAVEATS
The time at which an event will run is determined completely by the requests made to the application. Apps with heavy traffic may have events run at very close to the correct time, whereas apps with low levels of traffic may see events running much later than scheduled. If this is a problem, you can use a real cron entry that simply hits your application at the desired time. 0 * * * * wget -q http://www.myapp.com/ Events which consume a lot of time will slow the request processing for the user who triggers the event. For these types of events, you should use auto_run => 0 or manual event triggering. PERFORMANCE
The plugin only checks once per minute if any events need to be run, so the overhead on each request is minimal. On my test server, the difference between running with Scheduler and without was only around 0.02% (0.004 seconds). Of course, when a scheduled event runs, performance will depend on what's being run in the event. METHODS
schedule Schedule is a class method for adding scheduled events. See the "SCHEDULING"" in " section for more information. scheduler_state The current state of all scheduled events is available in an easy-to-use format by calling $c->scheduler_state. You can use this data to build an admin view into the scheduling engine, for example. This same data is also displayed on the Catalyst debug screen. This method returns an array reference containing a hash reference for each event. [ { 'last_run' => '2005-12-29 16:29:33 EST', 'auto_run' => 1, 'last_output' => 1, 'at' => '0 0 * * *', 'next_run' => '2005-12-30 00:00:00 EST', 'event' => '/cron/session_cleanup' }, { 'auto_run' => 1, 'at' => '0 0 * * *', 'next_run' => '2005-12-30 00:00:00 EST', 'event' => '/cron/build_rss' }, ] INTERNAL METHODS
The following methods are extended by this plugin. dispatch The main scheduling logic takes place during the dispatch phase. dump_these On the Catalyst debug screen, all scheduled events are displayed along with the next time they will be executed. setup SEE ALSO
crontab(5) AUTHOR
Andy Grundman, <andy@hybridized.org> COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2010-05-03 Catalyst::Plugin::Scheduler(3pm)
All times are GMT -4. The time now is 05:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy