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 8661261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:27:18+00:00 2026-06-12T16:27:18+00:00

I have a code like this : set -e set -x folderName=$(echo `date +%Y/%m/%d/`);

  • 0

I have a code like this :

set -e
set -x
folderName=$(echo `date +%Y/%m/%d/`);
fileName=x.x.x.x.x.x.x.log 
cp x.x.x.x.x.x/$1 $fileName  
gzip $fileName  
s3cmd put $fileName.gz s3://x.x.x.x.x/$folderName    
rm $fileName.gz

This is working fine if I run like this :

./shell logfilelocation

And when I added into the crontab like this :

* * * * * /home/x.x.x/testing/s3 -f x.x.x.log >> /tmp/mys3Log

And I waited! The file mys3Log gets created. But there is no content in it! I expect the result of command execution ( as I have used set -e ; set -x in my code ) should go into the mys3Log file as I’m doing a redirect there.

But something is going wrong. I’m very new to bash programming and cron.

Where I’m making the mistake?

Thanks in advance.

  • 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-12T16:27:19+00:00Added an answer on June 12, 2026 at 4:27 pm

    cron don’t have the same environment like in interactive shell, so at the beginning of the script, after the shebang, add :

    source ~/.bashrc || source /etc/profile
    

    And remove set -e to see what’s going on.

    In your crontab, to log errors & output (STDERR, STDOUT), you need to do :

    * * * * * /home/x.x.x/testing/s3 -f x.x.x.log >> /tmp/mys3Log 2>&1
    

    Moreover, on line 4 of your script, you are using the variable $name thats is never declared.

    Last but not least, like Janauary said, add the #!/bin/bash shegang on the first line and ensure that your script have executable rights. : chmod +x script.sh

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

Sidebar

Related Questions

I have code like this: public bool Set(IEnumerable<WhiteForest.Common.Entities.Projections.RequestProjection> requests) { var documentSession = _documentStore.OpenSession();
I have a piece of code like this: HashSet<Object> Set = new HashSet<Object>(); //add
I have some code like this: Update table_name set [column] = case when d.data
so i have a code like this: if ($var == null || 'NULL'){ echo
I have a piece of code like this: set<string>::iterator it1; set<string>::iterator it2; pair<set<string>::iterator,bool> ret;
I have PHP code like this: $query = 'UPDATE `user_vote` SET `container` = CONCAT(`container`,
I have a code like this: #!/usr/bin/env bash test_this(){ export ABC=ABC echo some output
I have some code that looks like this: std::set<int> s1, s2, out; // ...
I have code like this in my view model: function ChatListViewModel(chats) { var self
I have code like this - (IBAction)onClick:(id)sender { NSThread *thread = [[NSThread alloc]initWithTarget:parser selector:@selector(adapter:)

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.