10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies
2. UNIX and Linux Applications
Hi
I would like to check if an instance of a script is already running.
I've seen many different examples, but I haven't the slightest idea as to how to do this.
Can you please help.
Thank you. (5 Replies)
Discussion started by: ladyAnne
5 Replies
3. Shell Programming and Scripting
Hi ,
I have a csh code below which check the process if it's running.
Can any expert advise me on the following:
1) what does this notationmean ">!" and how is it different from the append ">" notation ?
2) how does "setenv" work in this code ?
# Check whether there is a running... (3 Replies)
Discussion started by: Raynon
3 Replies
4. Shell Programming and Scripting
Hi..
I have this code which tells me that if a process is running or not. Actually someone on this forum help me to do it. :) But now If i want to check if the process is not running for more than 10 minutes. Does anyone know the code or syntax that checks if a process is not running for some... (1 Reply)
Discussion started by: kanexxx
1 Replies
5. Solaris
How to find what are the cron jobs which are running at any instant on a Solaris server ??? The job can be scheduled from any id but still would like to list all the cron jobs which are running on the server ??? (2 Replies)
Discussion started by: helper
2 Replies
6. UNIX for Dummies Questions & Answers
Hi Everybody
I have small requirement that needs to be implemented in shell script.
Currently i have shell script which invokes a java process say "Process A" which runs in background.
If some one tries to invoke again the same shell script , then there should be some mechanism inside the... (23 Replies)
Discussion started by: appleforme1415
23 Replies
7. UNIX for Dummies Questions & Answers
Except the command "top" , is there other function / tool is used to check the process status in the system like
1. what process are running ?
2. how the CPU are allocating ?
3. how many swap is using ?
4. "
Thx. (1 Reply)
Discussion started by: ust
1 Replies
8. Shell Programming and Scripting
how to kill the process that are idle over 30 minutes ? thx (2 Replies)
Discussion started by: ust
2 Replies
9. UNIX for Advanced & Expert Users
Hi,
Is there any way in Unix to check for the system usage processwise ??
I mean I wud like to get a listing of running processes along with their CPU / memory utilisation so that I can spot dangerous the space / memory eaters ..
Thanks & regards,
SNS (2 Replies)
Discussion started by: Sabari Nath S
2 Replies
10. UNIX for Dummies Questions & Answers
does anyone know an easy way that at the beginning of your script you check to see if that process is already running? I think it would have something to do with ps but I may be making it more complicated than it has to be. If you have a script run say, every half hour, you would want to check and... (13 Replies)
Discussion started by: k@ssidy
13 Replies
PARSE_TIME(3) BSD Library Functions Manual PARSE_TIME(3)
NAME
parse_time, print_time_table, unparse_time, unparse_time_approx, -- parse and unparse time intervals
LIBRARY
The roken library (libroken, -lroken)
SYNOPSIS
#include <parse_time.h>
int
parse_time(const char *timespec, const char *def_unit);
void
print_time_table(FILE *f);
size_t
unparse_time(int seconds, char *buf, size_t len);
size_t
unparse_time_approx(int seconds, char *buf, size_t len);
DESCRIPTION
The parse_time() function converts a the period of time specified in into a number of seconds. The timespec can be any number of <number
unit> pairs separated by comma and whitespace. The number can be negative. Number without explicit units are taken as being def_unit.
The unparse_time() and unparse_time_approx() does the opposite of parse_time(), that is they take a number of seconds and express that as
human readable string. unparse_time produces an exact time, while unparse_time_approx restricts the result to only include one units.
print_time_table() prints a descriptive list of available units on the passed file descriptor.
The possible units include:
second, s
minute, m
hour, h
day
week seven days
month 30 days
year 365 days
Units names can be arbitrarily abbreviated (as long as they are unique).
RETURN VALUES
parse_time() returns the number of seconds that represents the expression in timespec or -1 on error. unparse_time() and
unparse_time_approx() return the number of characters written to buf. if the return value is greater than or equal to the len argument, the
string was too short and some of the printed characters were discarded.
EXAMPLES
#include <stdio.h>
#include <parse_time.h>
int
main(int argc, char **argv)
{
int i;
int result;
char buf[128];
print_time_table(stdout);
for (i = 1; i < argc; i++) {
result = parse_time(argv[i], "second");
if(result == -1) {
fprintf(stderr, "%s: parse error
", argv[i]);
continue;
}
printf("--
");
printf("parse_time = %d
", result);
unparse_time(result, buf, sizeof(buf));
printf("unparse_time = %s
", buf);
unparse_time_approx(result, buf, sizeof(buf));
printf("unparse_time_approx = %s
", buf);
}
return 0;
}
$ ./a.out "1 minute 30 seconds" "90 s" "1 y -1 s"
1 year = 365 days
1 month = 30 days
1 week = 7 days
1 day = 24 hours
1 hour = 60 minutes
1 minute = 60 seconds
1 second
--
parse_time = 90
unparse_time = 1 minute 30 seconds
unparse_time_approx = 1 minute
--
parse_time = 90
unparse_time = 1 minute 30 seconds
unparse_time_approx = 1 minute
--
parse_time = 31535999
unparse_time = 12 months 4 days 23 hours 59 minutes 59 seconds
unparse_time_approx = 12 months
BUGS
Since parse_time() returns -1 on error there is no way to parse "minus one second". Currently "s" at the end of units is ignored. This is a
hack for English plural forms. If these functions are ever localised, this scheme will have to change.
HEIMDAL
October 31, 2004 HEIMDAL