我可以.bash_profile
在用户登录系统时运行命令。我想禁止在特定时间登录。算法:
if((HOUR(now) == 13) || (HOUR(now) < 7))
exit
我知道,如何在 C 中做这样的事情:
#include <stdio.h>
#include <time.h>
int main(int argc, char *argv[])
{
time_t rawtime; time (&rawtime);
struct tm *tm_struct = localtime(&rawtime);
int hour = tm_struct->tm_hour;
if((hour == 13) || (hour < 7))
{
printf("hi\n");//exit will be used instead
}
return 0;
}
但我不知道如何在 bash 中实现它。