![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automate FTP process and autorestart on link failure | sdcoms | IP Networking | 5 | 08-14-2008 06:45 PM |
| vmstat vs uptime? | gfhgfnhhn | UNIX for Advanced & Expert Users | 2 | 08-28-2006 05:06 AM |
| uptime | qfwfq | UNIX for Dummies Questions & Answers | 1 | 06-16-2006 02:38 PM |
| Getting uptime | Freefall | UNIX for Dummies Questions & Answers | 2 | 06-17-2003 05:10 PM |
| uptime | xiamin | UNIX for Dummies Questions & Answers | 2 | 02-19-2003 04:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
script to autorestart if uptime greater than... help needed.
i'm trying to write a script that will check my os x box for uptime and autorestart gracefully if the uptime is greater than a certain number of days.
thus far i have this: if uptime | cut -d ',' -f 1 | cut -d ' ' -f 4 -gt 10 ; then echo "yes" fi this doesn't work and i've tried brackets, parenthesis, etc to get it to work. can someone direct me to the correct syntax please? thanks! |
|
||||
|
Quote:
removing the middle part to return the value i'm looking for still doesn't work either: if test `uptime | cut -d "," -f 1 | cut -d " " -f 4` -gt 10 ; then echo "yes" fi it doesn't return "yes". i'm using bash. thanks |
|
||||
|
Quote:
|
|
|||||
|
1)which quote are u using ? Is it the one below ESC key on the key-board.
You have to use that quote only. 2) If that does n't work .... put that whole command to variable and include that variable for ' if ' syntax. var = `uptime | cut -d "," -f 1 | tr -s " " | cut -d " " -f 4` if test $var -gt 10 then echo "Yes" fi 3) Check 'if' syntax as per apple OS. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|