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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:18:25+00:00 2026-05-15T04:18:25+00:00

I have a script that I’m trying to run from cron. When I run

  • 0

I have a script that I’m trying to run from cron. When I run it from bash, it work just fine. However when I let cron do it’s thing, I get a:

myscript.sh: line 122: syntax error: unexpected end of file

What I want is a way to run a command as if it was a cron job, but do it in my shell.

As a side note: does anyone know what would be differnt under cron? (the script already has a #!/bin/sh line)


To answer my own question: I added this to my crontab:

*  *   * * *    bcs     for ((i=$(date +\%M); i==$(date +\%M) ;)) ; do find ~/.crontemp/ -name '*.run' -exec "{}" ";" ; sleep 1; done`

and created this script:

#!/bin/sh
tmp=$(mktemp ~/.crontemp/cron.XXXXX)
mknod $tmp.pipe p
mv $tmp $tmp.pre
echo $* '>' $tmp.pipe '1>&2' >> $tmp.pre
echo rm $tmp.run >> $tmp.pre
chmod 700 $tmp.pre
mv $tmp.pre $tmp.run
cat $tmp.pipe
rm $tmp.pipe

With that, I can run an arbitrary command with a delay of not more than one second.

(And yes, I know there are all kinds of security issue involved in that)

the problem was a fi vs. if problem. Doh!

  • 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-15T04:18:25+00:00Added an answer on May 15, 2026 at 4:18 am

    There are a number of things it could be – output will be redirected elsewhere; environment variables will almost certainly be different, etc. On the information you’ve given, it could be related to a difference between bash and /bin/sh (which on some systems – including Debian/Ubuntu flavors of Linux – are different, and support slightly different syntax). Cron will usually run the command you give to it using /bin/sh.

    Try running:

    /bin/sh -c '<command>'
    

    where <command> comes from your crontab. (Of course, if that command uses '' quotes you will need to modify it accordingly…)

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

Sidebar

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.