- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script giving error throuh crontab
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
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
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
тАО03-11-2009 11:40 PM
тАО03-11-2009 11:40 PM
script giving error throuh crontab
I have facing a problem in a scripting pls me out. When i m running the script manually it woking fine but through cron tab it is giving error in below portion.
echo "Total swap utilisation is echo "Total swap utilisation is `swap -s | awk '
{
swapused = $9
swapavail = $11
swapusedlen = length(swapused) - 1
swapavailen = length(swapavail) - 1
usedk = substr(swapused,1,swapusedlen)
availk = substr(swapavail,1,swapavailen)
total = availk + usedk
percentage = (usedk / total)*100
printf("%3.0f %\n", percentage)
}'`" >> checklist_$d1
instead of print the value of percentage, it is same percentage in output.
but manually its work
- Tags:
- cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2009 11:46 PM
тАО03-11-2009 11:46 PM
Re: script giving error throuh crontab
you must use the full path to the commands in the script.
OR
do PATH=.... at the top of the script and include all necessary paths.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 12:29 AM
тАО03-12-2009 12:29 AM
Re: script giving error throuh crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 02:39 AM
тАО03-12-2009 02:39 AM
Re: script giving error throuh crontab
i have tried same but still same probelm
pls look into the changes:--
PATH=$PATH:/usr/symcli/bin:/usr/local/bin:/usr/sbin:/usr/bin
export PATH
echo "Total swap utilisation is `/usr/sbin/swap -s | /usr/bin/awk '
{
swapused = $9
swapavail = $11
swapusedlen = length(swapused) - 1
swapavailen = length(swapavail) - 1
usedk = substr(swapused,1,swapusedlen)
availk = substr(swapavail,1,swapavailen)
total = availk + usedk
percentage = (usedk / total)*100
printf("%3.0f %\n", percentage)
#print $percentage
}'`" >> checklist_$d1
and output is:--
Total swap utilisation is %n, percentage)
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 03:59 AM
тАО03-12-2009 03:59 AM
Re: script giving error throuh crontab
Several things are amiss here.
1. There is no 'swap' command for HP-UX. What operating system is this? Did you mean to use 'swapinfo -tam' ?
2. There is an extra double quote following the closing curly brace of the 'awk' script.
3. You can't run the posted snippet in 'cron' unldess you _define_ the 'd1' variable you use in 'checklist_$d1'. Cron tasks do _not_ inherit anything in your login 'profile' since it is not sourced (read) when the crontask is initiated.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:39 AM - edited тАО09-03-2011 10:04 PM
тАО03-12-2009 10:39 AM - edited тАО09-03-2011 10:04 PM
Re: script giving error through crontab
>printf("%3.0f %\n", percentage)
awk(1) doesn't show that you can use () around printf, just:
printf "%3.0f %%\n", percentage
(And you need to double up the literal "%".)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 10:49 AM
тАО03-12-2009 10:49 AM
Re: script giving error throuh crontab
> Dennis: awk(1) doesn't show that you can use () around printf, just: printf "%3.0f %%\n", percentage
Yet this works just fine:
# awk 'END{printf("%3.0f %\n",95.9)}' /dev/null
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 11:41 AM
тАО03-12-2009 11:41 AM
Re: script giving error throuh crontab
well..it might run and produce "checklist_".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 11:47 AM
тАО03-12-2009 11:47 AM
Re: script giving error throuh crontab
> OldSchool: well..it might run and produce "checklist_".
Yes, that's correct, of course, and I should have said that explicitly rather than inferring "can't" to be equivalent to "should not". I was trying to make the point that the user's environment is not necessarily going to be the same as a login environment unless steps are taken. :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-12-2009 09:07 PM
тАО03-12-2009 09:07 PM
Re: script giving error throuh crontab
>JRF: Yet this works just fine:
# awk 'END {printf("%3.0f %\n",95.9)}' /dev/null
Ah, the Posix standard does allow the optional (). But that missing %% is clearly an error. If you use:
awk 'END{printf("%3.0f % depth\n",95.9)}' /dev/null
You'll get an error, since "% d" is a valid format:
awk: There are not enough parameters in printf statement %3.0f % depth