NoTrust
NoTrust

Reputation: 207

Linux kernel development

I want to run some script/binary after system start and every 1000 ms (for example) inside Linux kernel (without the use of software as a crontab and kernel modules). Where can I put such code:

#include <linux/kmod.h>

char *envp[] = { "HOME=/", NULL };
char *argv[] = { "/bin/ls", NULL };

call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);

Upvotes: 1

Views: 316

Answers (1)

osgx
osgx

Reputation: 94245

Try to use kernel timer API:

https://www.ibm.com/developerworks/library/l-timers-list/

The simplest method is a call to setup_timer, which initializes the timer and sets the user-provided callback function and context. Otherwise, the user can set these values (function and data) in the timer and simply call init_timer. Note that init_timer is called internally by setup_timer"

void init_timer( struct timer_list *timer );
void setup_timer( struct timer_list *timer, 
                 void (*function)(unsigned long), unsigned long data );

Upvotes: 2

Related Questions