LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-31-2002, 12:21 AM   #1
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Rep: Reputation: 30
just wondering this while driving my car today ...


Hi. Im new (sorta) 5months or so ) to linux and begining C programming (8 months on/off) and wanna learn bash and python and eventually assembly.
Anyways I was driving today listening to the Deftones (which I burned on linux using mkisofs and cdrecord ) (no front-ends for me) ( <--- none of this has anything to do with my question by the way) and a question came to my mind about programming. > Is it possible to have a program sit on a HDD and
auto-execute after a certain amount of time (say a month or so) or would it have to be running for the clock to do the counting (for the month or whatever) ? I mean without the help of any other programs. I think the answer would be NO. Just wanted to know what any experienced programmers new.


thanks
 
Old 07-31-2002, 12:24 AM   #2
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
from what I've read of the man pages, you mean a "cron job".

$man cron
 
Old 07-31-2002, 12:30 AM   #3
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Original Poster
Rep: Reputation: 30
thanks
 
Old 07-31-2002, 04:21 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well cron is an application. It just checks if it has any scheduled events and executes them at the appropriate time. So making it a cron job will be running it with the help of another application.

There has to be something that triggers the execution of an application. Since the kernel doesn't do this it's up to other applications to do this. Most people use cron (or a cron like program) to execute applications at a scheduled time.
 
Old 07-31-2002, 07:38 AM   #5
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
You could write a kernel module which executed the application periodically, but there'd be no point, obviously...
 
Old 07-31-2002, 10:09 AM   #6
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
Speaking of modules, how could I compile one? THere is an example in this book I have but I fear the 2.4.18 kernel has it's diffrences. I tried
Code:
gcc -o first.o first.c -D__KERNEL__ -I/usr/src/linux/include -DMODULE -Wall -O2
but no luck .... just alot of link errors
 
Old 07-31-2002, 02:35 PM   #7
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It's a problem with PATH. What directory was the module in? How is your library path set (in ld.so.conf)?
 
Old 07-31-2002, 11:58 PM   #8
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
the module source is in [way] under my home directory :
/home/lackluster/cstuff/modules/first.c

I don't get your second question. This is the contents of it :
Code:
/usr/local/lib
/usr/X11R6/lib
/usr/i386-slackware-linux/lib
/opt/gnome/lib
/usr/openwin/lib
/usr/lib/qt/lib
/opt/kde/lib
 
Old 08-01-2002, 04:57 AM   #9
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
ld.conf.so looks good.
Are you sure that /usr/src/linux is the directory with the right version of kernel? The one your module is for?
Module for 2.2.x kernel won't work with 2.4.x kernel....
 
Old 08-01-2002, 07:06 AM   #10
kgwagner
LQ Newbie
 
Registered: Jul 2002
Location: Southeast Michigan, USA
Distribution: Red Hat, SuSE, Mandrake, Lycoris
Posts: 4

Rep: Reputation: 0
You're right - the answer is no. Something has to be running, keeping track of time - either the app your want to start percolating, or cron (or something like it). Cron already works, so...

You could have your app run, keeping track of time until some fateful moment, but it's likely it would consume considerably more resources than cron would to do the same thing.

Incidentally, there are a number of calendar programs you can have start at boot that will pop reminders for you, if that's where you're going with this.
 
Old 08-01-2002, 10:27 AM   #11
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
Quote:
Originally posted by Mara
ld.conf.so looks good.
Are you sure that /usr/src/linux is the directory with the right version of kernel? The one your module is for?
Module for 2.2.x kernel won't work with 2.4.x kernel....
yeah /usr/src/linux is 2.4.18 (I should know I've built it enough ). The module isn't for any specific kernel. This is what I found in this book thus this is what I've tried :

{ first.c }
Code:
#include <linux/module.h>

#if defined(CONFIG_SMP)
#define __SMP__
#endif

#if defined(CONFIG_MODVERSIONS)
#define MODVERSIONS
#include <linux/modversions.h>
#endif

#include <linux/kernel.h>

int init_module(void) {
	printk(KERN_DEBUG "Hello, Kernel!\n");
	return 0;
}

void cleanup_module(void) {
	printk(KERN_DEBUG "Later, Kernel!\n");
}
 
Old 08-01-2002, 01:25 PM   #12
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
The code looks good (for an 2.2.x module, but should be also good for 2.4.x). Could you paste your error messages? It seems it's all about pathes.
 
Old 08-01-2002, 01:28 PM   #13
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
sh-2.05a$ make
gcc -o first.o first.c -D__KERNEL__ -I/usr/src/linux/include \
-DMODULE -Wall -O2
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
/tmp/cca6ySeP.o: In function `init_module':
/tmp/cca6ySeP.o(.text+0xf): undefined reference to `printk_R1b7d4074'
/tmp/cca6ySeP.o: In function `cleanup_module':
/tmp/cca6ySeP.o(.text+0x27): undefined reference to `printk_R1b7d4074'
collect2: ld returned 1 exit status
make: *** [first.o] Error 1
 
Old 08-01-2002, 02:28 PM   #14
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Try this:
gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -O2 -I/usr/src/linux/include -c first.c
I compiled it on my machine this way (kernel 2.2.20), but should work also for you.
 
Old 08-01-2002, 05:33 PM   #15
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
Ah so! Your patience and help is much appreciated, Mara. It worked. The only difference I see here is that you defined LINUX (-DLINUX). What's that about? Anyways, thanks greatly for your help - hopefully someday I'll make a driver you'll want/need and then you'll be glad you helped me so long back . You rock.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
if linux was a car... egag General 12 08-26-2005 09:12 PM
New Car Smell hugoh80 LinuxQuestions.org Member Intro 6 08-06-2005 01:17 AM
Computer on my car!?? FreakboY Linux - General 7 03-14-2005 06:35 PM
How to buy a car? mikeshn General 11 08-30-2004 03:04 PM
first car suggestions? randyriver10 General 12 08-09-2004 10:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration