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

  • SEARCH
  • Home
  • 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 8860931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:22:34+00:00 2026-06-14T15:22:34+00:00

I have a ruby script that connects to an Amazon S3 bucket and downloads

  • 0

I have a ruby script that connects to an Amazon S3 bucket and downloads the latest production backup. I have tested the script (which is very simple) and it works fine.

However, when I schedule this script to be run as a cron job it seems to fail when it loads the Amazon (aws-s3) gem.

The first few lines of my script looks like this:

#!/usr/bin/env ruby
require 'aws/s3'

As I said, when I run this script manually, it works fine. When I run it via a scheduled cron job, it fails when it tries to load the gem:

`require’: no such file to load — aws/s3 (LoadError)

The crontab for this script looks like this:

0 3 * * * ~/Downloader/download.rb > ~/Downloader/output.log 2>&1

I originally thought it might be because cron is running as a different user, but when I do a ‘whoami’ at the start of my ruby script it tells me it’s running as the same user I always use.

I have also done a bundle init and added the gem to my gemfile, but this doesn’t seem to have any affect.

Why does cron fail to load the gem? I am running Ubuntu.

  • 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-06-14T15:22:36+00:00Added an answer on June 14, 2026 at 3:22 pm

    If you’re running it manually and it works you’re probably in a different shell environment than cron is executing in. Since you mention you’re on Ubuntu, the cron jobs probably execute under /bin/sh, and you’re manually running them under /bin/bash if you haven’t changed anything.

    You can debug your environment problems or you can change the shell that your job runs under.

    To debug, There are several ways to figure out what shell your cron jobs are using. It can be defined in

    /etc/crontab
    

    or you can make a cron job to dump your shell and environment information, as has been mentioned in this SO answer: How to simulate the environment cron executes a script with?

    To switch to that shell and see the actual errors causing your job to fail, do

    sudo su
    env -i <path to shell> (e.g. /bin/sh)
    

    Then running your script you should see what the errors are and be able to fix them (rubygems?).

    Option 2 is to switch shells. You can always try something like:

     0 3 * * * /bin/bash -c '~/Downloader/download.rb > ~/Downloader/output.log 2>&1'
    

    To force your job into bash. That might also clear things up.

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

Sidebar

Related Questions

I have a simple Ruby script that uses the rb-appscript gem to control iTunes,
I have a simple Ruby script that looks like this require 'csv' while line
I have the following Ruby script that creates a Debian package, which works fine:
I have a ruby script that downloads URLs from an RSS server and then
I have a Ruby script which downloads YouTube Insight reports for specific videos within
I have Ruby script that creates a proxy so that I can make HTTP
so i have ruby script that simply writes to a test.txt file with hello
I have a ruby script that opens a browser. I have it set to
I have a ruby script that does a few perforce operations (through the scripting
I have a ruby script that is simultaneously and asynchronously receiving and displaying messages

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.