简体   繁体   中英

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);

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 ); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM