百度了一下,一般守護(hù)進(jìn)程的工作形式是:監(jiān)聽端口,有數(shù)據(jù)來(lái)了就fork()子進(jìn)程對(duì)數(shù)據(jù)進(jìn)行處理。
小弟現(xiàn)在需要編寫一個(gè)分布式任務(wù)處理的程序,這個(gè)任務(wù)手工執(zhí)行的方式是:
1、普通用戶登錄server;
2、手動(dòng)加載profile以及掛載網(wǎng)絡(luò)文件系統(tǒng);
3、執(zhí)行程序(因?yàn)槌绦蛟贜FS上面才有)。
這種任務(wù)執(zhí)行方式,怎么用守護(hù)進(jìn)程實(shí)現(xiàn)呢?畢竟手工執(zhí)行任務(wù)需要以普通用戶身份登錄控制終端,而守護(hù)進(jìn)程屬于超級(jí)用戶,并且是不屬于某個(gè)控制終端的。
問(wèn)題是守護(hù)進(jìn)程怎么模擬任務(wù)手工執(zhí)行這三個(gè)步驟?因?yàn)檫@個(gè)任務(wù)需要某個(gè)用戶控制終端所屬的進(jìn)程來(lái)執(zhí)行。
光陰似箭催人老,日月如移越少年。
I don’t understand what you mean. Port monitoring does not distinguish between user permissions. Ordinary users can also send sockets to daemons created by super users. I don’t know where you can’t figure it out.
The above two parts can be done with shell programming
I won’t go into details if ssh is configured and used to log in with a certificate.
Ssh can be followed directly by the file name, which is to execute a certain command after the login is completed
As for hanging on the network file system and executing a specific program, it can be written in the command script executed when logging in