Home > cron > how to make cron run once at specific time per day?

how to make cron run once at specific time per day?

May 20Hits:12
Advertisement

I want the cron run only once at say 01:00 hours after midnight, just to save shared hosting resources as cron empties the caches. My new site is using too much of resources and I'm trying my best to stick with shared hosting. I want to set cron run once in a day. It should run at midnight so that some cache is built before day time, when traffic is high.

I've only two somewhat related threads: make sure hook cron is only run once a day setting and How do I run cron more often than every hour

But for such simple thing it don't want to use Elysia module.

From this post: How do I get the (date)timestamp since last cron run? I understand if we manually set cron_last variable then may be next cron time will be calculated with respect to this.

Another way I can do is to run drush cron from a script from crontab which will run it at a particular time. Similarly we can call cron from crontab ( as in here).

I'd want it to be done from within a module etc so that whenever I move my site, it'll work at any new setup without doing any configuration.

Any suggestions?

Answers

I think you've covered the options well in your question. However, your combinaton of requirements - i.e.:

  1. no poking of cron.php from crontab;
  2. settings kept in database to be migrated along with the site ("done from within a module");
  3. the management module must not be Elysia.

is a problem. This combination excludes all the possible answers. There is no solution that will satisfy all three requirements.

If you want to use a module, that module is Elysia cron.

You seem to think Elysia cron is overkill for this. I happen to agree. Besides, Elysia does not work too well when triggered by the built-in default poorman's cron. You really want to use an external crontab poke together with Elysia to get the type of fine-grained control you seem to be after, with Elysia.

So while your first requirement rules out poking of cron.php from crontab, that is my suggested solution.

Actually, since the crontab entries for all your sites can be kept in a single file on a single server, I do not see how this set-up should be considered too difficult to maintain.

Tags:cron

Related Articles

  • how to make cron run once at specific time per day?May 20

    I want the cron run only once at say 01:00 hours after midnight, just to save shared hosting resources as cron empties the caches. My new site is using too much of resources and I'm trying my best to stick with shared hosting. I want to set cron run

  • Devel output on hooks called during cron runFebruary 3

    I'm implementing a hook that is called if certain conditions are met during a cron run. (Specifically hook_bounce_mails_blocked($mails) from the Bounce module) The hook is triggered, but any output from dpm() functions is never shown. I do see output

  • How to run a cron job as a specific user?August 2

    I would like to run a cron job as a specific user on my machine. How may I specify the user for a cron job to run as?. I am running on Ubuntu 10.0.4 [Edit] The cron jobs will be running on a server. The 'users' are users that have been created specif

  • How to configure cron to run jobs using specific timezone timesOctober 24

    We have a system configured in local UK time - so its currently in BST and will be switching to GMT this coming weekend. There are some reports scheduled with cron that are for users in Hong Kong. As they have no Daylight Savings Time, their clocks a

  • I can not find specific cron running at *:21 and *:56 on DebianJanuary 30

    I am frustrated. I have two mystic crons running on our server, that I can not find by doing crontab -l. The good thing is these crons are sending mails. That is how I know those are running at :21m and :56m every hour. I have root access and I have

  • How to edit every node of a content type on cron run?January 5

    On cron runs, I want to edit every node of a certain content type. I think this is implemented through hook_cron() but I can't find any documentation about this hook. How can I edit every node of a certain content type on cron runs? I need this becau

  • Disable cron jobs for a specific userJanuary 19

    I have a list of jobs in the crontabs for user1, user2. I want to prevent the jobs of user2 from running. I tried listing user2 in cron.deny, but that only prevents him from accessing his crontab. The jobs listed in user2's crontab still get executed

  • crontab running as a specific userJanuary 23

    I need to run a script daily. The script should be run as a specific user (ex. user1) not as root. So I put the cron file at /etc/cron.d and put the user name in the line (2nd column). But it gives an error saying that the command is not found. I sus

  • Help debugging "cron run exceeded the time limit"February 22

    I have written a custom module (for Drupal 7 and PHP 5.3) that utilizes hook_nodeapi() and doesn't allow access to a specific node type and simply redirects (with drupal_goto()) to the main listing page with a warning message. However I have a suspic

  • Scheduler module- not working even after cron run, But running scheduler(dmin/config/content/scheduler/cron) cron it is working

    Scheduler module- not working even after cron run, But running scheduler(dmin/config/content/scheduler/cron) cron it is workingAugust 18

    Installed 'Scheduler module' and try to publish a content on specific time,But it seems like it is not working. tried with 'Run cron manually' also, But it doesn't ,While trying with Scheduler light weight cron it is working My question is why it is

  • Run screen command with variable & tick through cron (cron run .sh)September 2

    I run screen command through cron, where the codes is in lorem.sh files. This is cron codes: * * * * * cd /home/z; ./lorem.sh Inside lorem.sh: screen -S screenname -X stuff $'\033[B' sleep 1 && screen -S screenname -X stuff 2 sleep 1 && sc

  • Scheduling a module to run at a specific timeOctober 23

    Is there any way to schedule a particular sub-module to run at a specific time? I found hook_cron but it seems to rely on a scheduled cron job in crontab to run cron.php and then cron.php calls hook_cron. I have multiple sub-modules that I would like

  • How do I create a rule to run during every cron run?March 11

    I'm creating rules for posting to twitter. However I need these rules to run every time cron runs. What is the best way to structure these rules so they send the appropriate post at the appropriate time? --------------Solutions------------- Rules has

  • cron runs but nothing happensAugust 4

    I have created a script called "forward_email.sh" and set permissions to 777. It contains the following line: echo "It worked: $(date)" >> /home/noc/email.log I created a cron job with the following line: */5 * * * * /home/noc/fo

  • CentOS Cron running at wrong time, 5hrs late (Logwatch)February 14

    Server: CentOS 5.2 with Logwatch 7.3-8.el5 I have a cronjob setup to run logwatch at 10:45pm daily. The cron runs and I get the logwatch email, but it's running at 4:30am. My server's time is behind by 30mins but that doesn't explain the hours delay.

  • cron running at different timezone and date command shows different time zoneApril 28

    I have CentOS and when I run date command in shell it return me something like: Thu Apr 28 14:08:20 GMT 2011 however cron jobs are running at PST time.Means if I specify 15 7 * * * command it will run at 7 PST not 7 GMT . Please tell me why this is h

  • How to make Feeds import only one post at a time when cron run?May 23

    I have a website which will import many images through Feeds. But Feeds import too much posts which affect the bandwidth. I want Feeds import only one post at a time when cron run. The setup: feeds-6.x-1.0-beta10 Drupal 6.20 --------------Solutions--

  • Why would my Cron run fail when run by system crontab, but succeed when run manually?July 1

    The Cron tasks on my website run perfectly fine if I manually execute cron. However, I have the server set up to automatically run cron every hour. When cron is executed automatically it fails... every time. The error message is always about memory u

  • How to abort a cron run?December 14

    I would like to have the ability to prevent cron from running based on a variable set in the database. I have created a hook_cron implementation in a module with an extremely low weight so it will presumably run before all other module's cron hooks.

  • ERROR:Cron run exceeded the time limit and was aborted. why?December 22

    My Drupal installation's cron runs fail when run manually or by cron script. I thought it might be the Simple News module, but I've disabled then uninstalled that and the problem is still present. My PHP max_execution_time is set to 120 seconds, but

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.139 s.