Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4022406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:28:15+00:00 2026-05-20T10:28:15+00:00

How do I create a background task for a rake task. I want it

  • 0

How do I create a background task for a rake task. I want it run every 15 minutes.

My statistik.rake in lib/tasks

desc "Importer statistikker"
namespace :reklamer do
  task :iqmedier => :environment do
          require 'Mechanize'
          agent = WWW::Mechanize.new
          agent.get("http://www.iqmedier.dk")
          form = agent.page.forms.first
          form.Username = 'username'
          form.Password = 'password'
          form.submit

          agent.page.link_with(:href => "/Publisher/Stats").click

          form = agent.page.forms.first
          form.submit

          @stats = agent.page.search('//tr')[-2].search('td').map{ |n| n.text }

          @existing = Reklamer.where(dato: @stats[0]).first
          if @existing.nil?
              Reklamer.create!(:virksomhed => 'Iqmedier', :dato => @stats[0], :unik_klik => @stats[1], :klik => @stats[2], :unik_vis => @stats[3], :vis => @stats[4], :leads => @stats[5], :ordre => @stats[6], :cpc => @stats[7], :earn => @stats[8])
          elsif @existing.dato != Date.today
          Reklamer.create!(:virksomhed => 'Iqmedier', :dato => Date.today, :unik_klik => 0, :klik => 0, :unik_vis => 0, :vis => 0, :leads => 0, :ordre => 0, :cpc => 0, :earn => 0)
          else
            @existing.update_attributes!(:unik_klik => @stats[1], :klik => @stats[2].to_i, :unik_vis => @stats[3], :vis => @stats[4], :leads => @stats[5], :ordre => @stats[6], :cpc => @stats[7], :earn => @stats[8])
          end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:28:16+00:00Added an answer on May 20, 2026 at 10:28 am

    Depending on your architecture, the simplest way in the Linux world is to set up a cron job:

    Create a file in /etc/cron.d and stick this in it:

    */15 * * * *   your_app_user   cd /your/app/path; rake reklamer:iqmedier RAILS_ENV=production
    

    This will run the job every 15 minutes (due to the */15).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a background thread that's owned by an object. When that
Background : I want to create a custom VB compiler, extending the original compiler,
I need to run a task every 10 mins from morning 9 AM to
I'm using this tutorial on AsyncTask with a task and a notification: https://eliasbland.wordpress.com/2011/03/11/an-example-of-how-to-run-a-background-task-and-report-progress-in-the-status-bar-using-asynctask-on-android/ What
What is the preferred way to create a background task for a Rails application?
Just wondering if is there a way to create background task in Android using
Possible Duplicate: Rails delayed job not working How do I create an background task
I'm trying to run a lenghty task in the background on the iPhone. I
In a spring application I want do some background computing. The task is that
I'm trying create a simple background periodic task using Django-Celery-RabbitMQ combination. I installed Django

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.