因为经常要在机房上实验课,便想在机房远程自己的电脑。
但是我们学校的ruijie是在8点才能认证的,于是便编写了个自动执行的脚本,在8点连接上ruijie。
环境:ubuntu12.04
首先,编写一个脚本test.sh,保存在/home/nevermore目录,代码如下:
#!/bin/sh
sudo mentohust
echo success
这个脚本用于启动ruijie
接着,我们打开/etc/crontab,我们可以看到如下内容:
# m h dom mon dow usercommand
17 ** * * root cd / && run-parts --report /etc/cron.hourly
25 6* * * roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6* * 7 roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 61 * * roottest -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
其中,m代表分钟,h代表小时,dom为day of month mon为月份 dow为day of week,我们在最后一行添加如下代码:
10 8 * * * root sudo /home/nevermore/test.sh
代表 系统将在每天的8点10分执行该目录下的test.sh脚本。
哈哈,ok,到此就完成操作啦~~