C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-06-2003, 10:14 AM   #1
Registered User
 
Join Date: Nov 2003
Posts: 3
scheduled running of a c file, checking date/time

I am using Redhat 9.0, gcc -

I am trying to write a simple c application that:

* starts when I turn the computer on
* checks to see what time and day it is
* if it is saturday, 8 p.m. it tells a different .c application to run

I found bits and pieces in the forum to help me, but I am not quite sure where to start. I have a basic understanding of C, but I havn't done anything with background (stealth?) applications or date/time. And I have mostly used mac before, still new to linux.

Thanks
playfight is offline   Reply With Quote
Old 11-06-2003, 10:32 AM   #2
Registered User
 
Join Date: Jan 2002
Location: Cardiff
Posts: 2,219
you could make it a cron job.
Brian is offline   Reply With Quote
Old 11-06-2003, 10:34 AM   #3
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,662
Type this at the command prompt
man crontab

Example line
00 20 * * Sat /path/to/my/saturday_program
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 11-07-2003, 09:23 AM   #4
Registered User
 
Join Date: Nov 2003
Posts: 3
trying out cron...

Thanks,

cron certainly seems to be the way to go, but I am not getting it to work.

I created a crontab for my user:
15 10 * * * /src/hello/ a.out

so at 10:15 I tried to run my c application called a.out that is in the path shown above. the test program just outputs the current time/date into the shell window, but nothing happened at 10:15.

any suggestions?
playfight is offline   Reply With Quote
Old 11-07-2003, 09:33 AM   #5
and the hat of Jobseeking
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,662
Well it won't output it to the current shell window - you may not even be logged in when cron runs

By default, cron will send mail to your local account on your machine.

If you want something in a specific file, then perhaps
15 10 * * * /src/hello/a.out > /home/me/log.txt
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 11-07-2003, 09:51 AM   #6
Registered User
 
Join Date: Aug 2002
Posts: 351
send your results to syslog within your C program.

Then just grep for them when you want to check.

Crond will send any data sent to stdout in a mail to the user who ran the cron job WHEN the program completes.
rotis23 is offline   Reply With Quote
Old 11-07-2003, 11:20 AM   #7
Registered User
 
Join Date: Nov 2003
Posts: 3
cron working!

Thanks everyone!
Cron was working, just not seeing it. Tried to make a log.txt, but nothing was being written to it. But at some point, the shell told me I had new mail, which I went and checked, so cron is running my app.
playfight is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory Address kevinawad C++ Programming 18 10-19-2008 10:27 AM
sequential file program needhelpbad C Programming 80 06-08-2008 01:04 PM
Can we have vector of vector? ketu1 C++ Programming 24 01-03-2008 05:02 AM
gcc link external library spank C Programming 6 08-08-2007 03:44 PM
Basic text file encoder Abda92 C Programming 15 05-22-2007 01:19 PM


All times are GMT -6. The time now is 06:12 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22