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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:54+00:00 2026-06-10T11:40:54+00:00

Following script when executed directly on the shell works fine but when executed via

  • 0

Following script when executed directly on the shell works fine but when executed via a cronjob is erroring out.

bash-3.00$ cat scr.sh 
#!/usr/local/bin/bash
DATE=$(date +%g%m%e)
INPUT_FILES=$DATE"_*.txt"
ALL_FILES=$DATE"*.txt"
echo INPUT=$INPUT_FILES
echo FILES=$ALL_FILES
for i in $(ls $INPUT_FILES); do echo $i; done

When directly executing works fine.

When installing the same via crontab and executing I get the following error message:

INPUT=120828_*.txt
FILES=120828*.txt
ls: 120828_*.txt: No such file or directory

For some reason the ls in the for loop is not able to interpret the embedded ‘*’.

Any ideas on what can be going wrong.

thanks for the help.

  • 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-10T11:40:55+00:00Added an answer on June 10, 2026 at 11:40 am

    Current working directory (CWD) is different when you run from cron. In the script you may want to first cd into the directory.

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

Sidebar

Related Questions

The following script works for me, but I wonder if it could be done
I have the following script which won't work when executed as a script, but
am reading out of a database with the following python script: cur.execute(SELECT * FROM
I am wondering is there any way to execute following shell script, which waits
Following Script isn't working in CHROME browser, IE is Fine. I've changed opener.document ...
The following script creates symlinks as expected, but the original file can never be
I have the following PHP script, But it seems to be always checking for
When I executed the following script, I am getting the following error. What should
I want the following script command to be executed automatically when ever I log
I created the following Greasemonkey script to be executed on Firefox for all websites.

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.