Linux 内核开发

Linux kernel development

我想在系统启动后 运行 一些 script/binary 并且在 Linux 内核中每隔 1000 毫秒(例如)(不使用软件作为 crontab 和内核模块) .我在哪里可以放这样的代码:

#include <linux/kmod.h>

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

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

尝试使用内核定时器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 );