[問題] linux c抓取時間的問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
uClinux
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
沒有
問題(Question):
各位大大,小弟因為現在要在linux上寫一個在我要的時間點,把資料寫到txt檔裡,我己經
寫好了,但因為我放到設備上時,如果手動啟動我寫的這隻程式,都沒有問題,但如果我加到
ini檔(開機時,會去自動執行的程式),就會有問題.程式執行到我設的那個時間點時,會進
入到zombie的狀態?人家是說我沒有按linux的邏輯下去寫程式才會這樣.
以下是我的程式碼,想請問什麼是按linux的邏輯
char time_buf[9];
struct tm *nowtime;
int lock_flag = 0;
void main(void)
{
time_t long_time;
FILE *my_File;
while(1)
{
time( &long_time );
nowtime = localtime( &long_time );
Sleep(1);
if( ( nowtime->tm_hour ) == 0) && ( nowtime->tm_min ) == 0) )
{
if( lock_flag == 0 )
{
sprintf( buf, "%d/%d/%d-%d:%d\n", ... ); //這裡是把時間寫到buf
my_File = fopen( "./backup.txt", "a+" );
fprintf( my_File, "%s", buf );
fclose( my_File );
lock_flag = 1;
}
}else{
lock_flag = 0;
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.11.102
→
09/13 15:41, , 1F
09/13 15:41, 1F
→
09/13 15:42, , 2F
09/13 15:42, 2F
→
09/13 16:01, , 3F
09/13 16:01, 3F
→
09/13 16:02, , 4F
09/13 16:02, 4F
→
09/13 16:02, , 5F
09/13 16:02, 5F
→
09/13 16:58, , 6F
09/13 16:58, 6F
→
09/13 16:59, , 7F
09/13 16:59, 7F
→
09/13 16:59, , 8F
09/13 16:59, 8F
→
09/13 17:30, , 9F
09/13 17:30, 9F
→
09/13 17:31, , 10F
09/13 17:31, 10F
→
09/13 17:31, , 11F
09/13 17:31, 11F
→
09/13 17:36, , 12F
09/13 17:36, 12F
→
09/13 17:37, , 13F
09/13 17:37, 13F
→
09/13 17:38, , 14F
09/13 17:38, 14F
→
09/13 17:45, , 15F
09/13 17:45, 15F
※ 編輯: jimmycch 來自: 114.32.11.102 (09/13 18:29)
各位大大,請問一下,因為我現在的uclinux無法重新build kernel,想請問一下,有沒有
辦法在不重build kernel的狀態下,加上crontab / atd / at的辦法?
※ 編輯: jimmycch 來自: 114.32.11.102 (09/15 18:12)
→
09/15 21:18, , 16F
09/15 21:18, 16F
→
09/16 15:16, , 17F
09/16 15:16, 17F
→
09/16 15:17, , 18F
09/16 15:17, 18F
→
09/16 15:18, , 19F
09/16 15:18, 19F
→
09/16 15:23, , 20F
09/16 15:23, 20F
→
09/16 15:25, , 21F
09/16 15:25, 21F
→
09/16 15:39, , 22F
09/16 15:39, 22F
→
09/16 15:42, , 23F
09/16 15:42, 23F
→
09/16 15:45, , 24F
09/16 15:45, 24F
→
09/16 15:47, , 25F
09/16 15:47, 25F
yvb大大,謝謝你的講解,busybox我有用過,但它裡沒有編進去,廠商也不教我,
想請問我可以只重編busybox嗎?而不去動到uclinux嗎?
※ 編輯: jimmycch 來自: 61.217.232.238 (09/17 22:56)
→
09/22 17:58, , 26F
09/22 17:58, 26F
→
09/22 17:59, , 27F
09/22 17:59, 27F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 3 篇):