View Full Version : scheduled running of a c file, checking date/time
playfight
11-06-2003, 10:14 AM
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
Brian
11-06-2003, 10:32 AM
you could make it a cron job.
Salem
11-06-2003, 10:34 AM
Type this at the command prompt
man crontab
Example line
00 20 * * Sat /path/to/my/saturday_program
playfight
11-07-2003, 09:23 AM
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?
Salem
11-07-2003, 09:33 AM
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
rotis23
11-07-2003, 09:51 AM
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.
playfight
11-07-2003, 11:20 AM
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.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.