![]() |
| | #1 |
| Registered User Join Date: Nov 2003
Posts: 3
| scheduled running of a c file, checking date/time 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 | |
| | #2 |
| Registered User Join Date: Jan 2002 Location: Cardiff
Posts: 2,219
| you could make it a cron job. |
| Brian is offline | |
| | #3 |
| and the hat of Jobseeking 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 |
| Salem is offline | |
| | #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 | |
| | #5 |
| and the hat of Jobseeking 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 |
| Salem is offline | |
| | #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 | |
| | #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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |