running a program for a specified time


 
Thread Tools Search this Thread
Top Forums Programming running a program for a specified time
# 1  
Old 07-06-2005
running a program for a specified time

how can i run a program for a specified time?
i need to print a current time during program execution.
# 2  
Old 07-06-2005
hi

1) for the second question
with the following tm structure in time.h u can get the current time

time_t curr = time(NULL);
struct tm *tom = localtime(&curr);

Current Year: tom->tm_year+1900,
current month: tom->tm_mon+1
Current Day: tom->tm_mday
Current Hour: tom->tm_hour
Current Minute: tom->tm_min
Current Second: tom->tm_sec

2) for the first question
using the above structure get the values at the beginning of program
and at intervals check for the time value accordingly
proceed or exit the program

hope this helps.
# 3  
Old 07-06-2005
Do you mean start the program at a certain time, ie., start it at 11:45?
Try man cron and man at.

If you mean run it for 1500ms then look into gettimeofday()
# 4  
Old 07-06-2005
thanks

Thanks. Your advice is very helpful.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Test program running taking much more time on high end server T5440 than low end server T5220

Hi all, I have written the following program and run on both T5440 and T5220 on same OS version. I found that T5540 server takes more time than T5220. Please find below the details. test1.cpp #include <iostream> #include <pthread.h> using namespace std; #define NUM_OF_THREADS 20... (17 Replies)
Discussion started by: sanjay_singh85
17 Replies

2. Shell Programming and Scripting

Running C program in UNIX

I want to run a C program from my BASH script. Here's some very basic simplified code of my bash script: #!/bin/bash echo "Run C program" ./main.c echo "Ran C program" Here's my main.c: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { ... (3 Replies)
Discussion started by: millsy5
3 Replies

3. UNIX for Advanced & Expert Users

How to keep program running after logout

Hello everyone. I am logged into a computer through ssh. I would like to run a program and have it keep running after I log out without screen (i forgot to run it). For example: ssh server user/comp~$ top & 12021 exit after that: ssh server user/comp~$ (something, maybe shell... (5 Replies)
Discussion started by: lepetal
5 Replies

4. Shell Programming and Scripting

Running C# program problem

Hi All, How to run c# program using shell script ? (1 Reply)
Discussion started by: srikar.ch
1 Replies

5. UNIX for Dummies Questions & Answers

Kill a running program?

Hello i'm trying to make a program which can find a running program on the system and kill it, then repeat that every 5 minutes. The name of the process is given with an argument. I have done this so far, but still not working. if $1 in $(ps -e) ; then kill $(pidof $1) sleep 5m fi (3 Replies)
Discussion started by: petel1
3 Replies

6. Shell Programming and Scripting

Help with Running More than One Program

Folks, I'm really new to scripting and was wondering if you could help me out. I have the following script that I inherited: #!/bin/bash # # Usage # From the agent directory: # ./run-any-agent AgentName # TAC_AGENT_HOME=`pwd` LIB=${TAC_AGENT_HOME}/lib CLASSPATH=.... (17 Replies)
Discussion started by: DTriniWay
17 Replies

7. UNIX for Dummies Questions & Answers

Running a program on boot!

Hi there! I tried to search for something like this here but couldn't find anything. I need to run a specific program when linux starts up. I need to run it after the rp-pppoe has started because this prog needs internet connection. I start the program by entering ./dynix start (its in my home... (4 Replies)
Discussion started by: D-Lexy
4 Replies

8. UNIX for Dummies Questions & Answers

Running a program

Hi.Iam new to Linux.i got linux 7.0 pro and dont know how to run programs. I want a perl interputer and i know i installed one but how do i run it ??? Also how do i run a C or C++ editor ?and how do i run cron ? (3 Replies)
Discussion started by: perleo
3 Replies

9. Shell Programming and Scripting

Running a program automatically

How can I make a program run automatically at a certain time of day? My problem is I need to make a small backup program that will back up a few files every day? (3 Replies)
Discussion started by: jvadn0
3 Replies

10. Programming

Running a compiled Program

Just getting into the Unix command line programming and am unable to run any program I write. I am using a Makefile and the source is compiling but when I enter the name of the output file I get back: bash: lab01exe.out: command not found I'm sure I am just dooing something simple... (2 Replies)
Discussion started by: Krebsbac
2 Replies
Login or Register to Ask a Question