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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:29:39+00:00 2026-06-14T10:29:39+00:00

I’ve been scratching my head on this for a while. I have a script

  • 0

I’ve been scratching my head on this for a while.
I have a script that is run by a root cron job.
The script executes, but there is a script inside the script that wont execute.
Here is what we will call scriptA

#!/bin/bash
lines=`wc -l < /var/www/log/addme`;
DATE=`date +%Y-%m-%d`

if [[ $lines > 4 ]];
then
echo " " > /var/www/log/addme
RESTART=/var/www/log/restart.sh
$RESTART
else
echo "No new hosts added" | wall
fi

Basically what the restart.sh script does is to restart a service.
Everything works just fine when I run them from terminal, but not as cron jobs…
I also tried to just put

./restart.sh
/var/www/log/restart.sh

But with same result.
Any thoughts?

  • 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-14T10:29:40+00:00Added an answer on June 14, 2026 at 10:29 am

    I suspect you’re running into problems with the minimal environment that cron runs its jobs with. The biggest thing is that the PATH is very minimal, and is your script is probably using some commands that can’t be found.

    If this is the problem, there are several ways to fix it: the easiest is generally to add an appropriate definition of PATH to the crontab file, before the entry that runs your script. Something like this:

    PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    0 * * * *       /var/www/log/scriptA
    

    The second is to add a similar assignment at the beginning of scriptA. The third option is to go through both of the scripts, and use full paths for all of the commands you use (e.g. /usr/bin/wc instead of just wc).

    BTW, there is also a problem with the test [[ $lines > 4 ]] — inside [[ ]], > does a string (alphabetical) comparison, not a numeric comparison. This is a problem because, alphabetically, 10 is less than 4. Use either [[ $lines -gt 4 ]] or (( lines > 4 )) to get a numeric comparison.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have an autohotkey script which looks up a word in a bilingual dictionary
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.