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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:40:28+00:00 2026-05-27T16:40:28+00:00

I am executing a daily script in ubuntu server via Cron which runs a

  • 0

I am executing a daily script in ubuntu server via Cron which runs a java file. I want to it to be included in if/else block such that if the java file is executed successfully its should send an echo message “successfull” and if it fails it should send an echo message “failed”.

Here are the existing lines for the script updateGroupScores.sh

java -classpath "/home/ubuntu/live/build/WEB-INF/lib/*:/var/lib/tomcat7/lib/*:/home/ubuntu/live/build/WEB-INF/classes/" com.generalsentiment.update.UpdateGroupScores > /var/gs/livecron/crongroupsentimentscores.log

i want to modify them something like –

if (java file runs successfull)
then
echo "cron job successfull"

else
then 
echo "cron job failed"

—
Thanks

  • 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-27T16:40:29+00:00Added an answer on May 27, 2026 at 4:40 pm

    If you can rely on the exit status of the Java command, then simply write:

    C1="/home/ubuntu/live/build/WEB-INF/lib/*"
    C2="/var/lib/tomcat7/lib/*:/home/ubuntu/live/build/WEB-INF/classes/"
    LOG="/var/gs/livecron/crongroupsentimentscores.log"
    
    if java -classpath "$C1:$C2" com.generalsentiment.update.UpdateGroupScores > "$LOG"
    then echo "cron job successful"
    else echo "cron job failed"
    fi
    

    Note that the output will be mailed to you (on some systems at least), or lost to /dev/null. The variables make everything fit better on the SO screen; I’d probably use them in a regular script too, though it would be a borderline decision.

    If you can’t rely on the exit status, you’ll have to do something else to decide whether it succeeded or not, but the general principle is very much the same regardless.

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

Sidebar

Related Questions

I have created a Python script that I want to run daily via a
Have documents stored in a file system which includes daily directories, e.g. 20050610. In
I have written a PHP script which generates an SQL file containing all tables
When executing the following (complete) SQL query on Microsoft SQL Server 2000: SELECT B.ARTIFACTTNS,
Aside from executing XP_CmdShell, which I have disabled in my SQL 2005 installation, what
I have a daily cron job that grabs 10 users at a time and
I have a timer job which has been deployed to a server with multiple
I'm attempting to communicate with a Java webservice via a .NET application, using a
when executing a Java application the process name given to it is usually java.exe
When executing this simple SQL Delete statement, I'm getting a timeout from SQL Server:

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.