- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need assistance with script...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2011 07:45 PM
тАО06-03-2011 07:45 PM
I created a script on Linux server. We work on a JOb scheduling tool which is TNG (very old software) just like maestro...Now I have made script to run around autoscan..autoscan in TNG means New day load (Like Jnext day in Maestro)...
Script work is to :
Checks on the TNG Tracking Database for jobs stuck in WRSRC(Waiting for resource) status. Job will start straight after Autoscan(1 AM) and run a 24-hour cyclic script with a sleep of 15 minutes between each interrogation. If the same jobs have been found in WRSRC status after 2 interrogations, then the following console message is issued:
├в CALLOUT - There are jobs stuck in WRSRC status. Investigate job log and escalate!├в
Issue is : I have made script in such a way that it should trigger at 01:00AM(Job will trigger it)...sleep for every 15 mins....and it will complete between 23:44 to 23:59)....however Job triggers it at 01:00 Am (GMt) and it completes right away...as per mt perception it should start @ 01:00 and complete @ night between 23:44 to 23: 59..
Here is the script attached:
Please assist asap...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 02:12 AM
тАО06-04-2011 02:12 AM
SolutionIn some situations, it might be worthwhile to make a second attempt at creating the dummy latest file if the first attempt fails, but in this case, it looks more like a copy/paste mistake.
As a result of this mistake, the majority of the script would be skipped if ${latest_listfile} did exist when the script was started.
Your attached script used a very strange and un-helpful indentation scheme. I let my Vim editor re-indent it using its default indentation rules for shell scripts. The result is much easier to follow.
Vim also helped me to find the above-mentioned mistake: its syntax highlighting coloured the "done" on line 95 with white-on-red to indicate an error. The syntax highlighting keeps track of command structures like if...then...else...fi, do...done and case...esac. On line 95, it was expecting another "fi" before "done", and flagged the "done" as an error because of that.
Attached is a fixed and re-indented version of your script.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 02:24 AM
тАО06-04-2011 02:24 AM
Re: Need assistance with script...
Thanks for replying...I really need to to this one ASAp..
Apologies for my mistake.. I think I paste the old sript.. attached is the one which is on server...
Can you please have a look at it now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 02:28 AM
тАО06-04-2011 02:28 AM
Re: Need assistance with script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 03:51 AM
тАО06-04-2011 03:51 AM
Re: Need assistance with script...
Firstof there are two directories in it Logs and Scripts....they did not have the wrire permissions...
Now one challenge which I am facing is
Script is running when I login with sudo and type
sh -x script name....
However how can I run it as a sudo from JOb...
Job is using normal username and password
and If I will add
sudo su - in script it will wait for someone to enter password..
how do I go about it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 05:11 AM
тАО06-04-2011 05:11 AM
Re: Need assistance with script...
> However how can I run it as a sudo from JOb
If want the 'JOb' user to be able to execute your script edit the 'sudoers' file to allow your script.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 09:39 AM
тАО06-04-2011 09:39 AM
Re: Need assistance with script...
As MK mentioned please fix your indentation. This helps you and us understand your script better.
>while [ `date +%H%M` -le 2359 -o `date +%H%M` -ge 0100 ]; do
This range check isn't useful. Why not replace it by: :-)
while true; do
You probably want:
while (( $(date +%H%M) >= 0100 && $(date +%H%M) <= 2359 )); do
Note: The AND. And I usually put the lower bound first.
Your other range check seems fine.
># Pre-delete Files
>if [ -f ${old_listfile} ]
Why work so hard?
rm -f ${old_listfile}
if [ $? -ne 0 ]; then
echo "Delete of ${old_listfile} failed"
fi
Add mv -f here:
mv ${latest_listfile} ${old_listfile}
>grep "${jobset} ${job} ${jno} ${qual}" $old_listfile >>/dev/null
Better to use grep -q:
grep -q "${jobset} ${job} ${jno} ${qual}" $old_listfile
And can remove the evil cat from:
cat $latest_listfile | while read jobset job jno qual; do
while read jobset job jno qual; do
...
done < $latest_listfile
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-04-2011 09:45 AM
тАО06-04-2011 09:45 AM
Re: Need assistance with script...
You may have to change 0100 to 100, the posix shell may convert this to stinkin' octal.