全球主机交流论坛

标题: Debian12中的定时怎么设置? [打印本页]

作者: Telegramr    时间: 2024-2-3 18:28
标题: Debian12中的定时怎么设置?

我以前都是使用centos,所以对crontabe懂一些,但是我发现换到debian12之后, apt install cron 或者apt install cronie都安装不上,系统要求使用systemd,请大佬指点,谢谢了

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package corntab
root@ip-:/home/hostloc# apt install corn
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package corn
root@ip-:/home/hostloc# apt install cronie
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package cronie is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  systemd-cron cron-daemon-common cron bcron

作者: 笑花落半世琉璃    时间: 2024-2-3 18:32
  1. crontab -e
复制代码


简单好用,还安装啥
作者: Kanna    时间: 2024-2-3 18:33
root@ip-:/home/hostloc# apt install corn
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package corn
作者: Telegramr    时间: 2024-2-3 18:34
笑花落半世琉璃 发表于 2024-2-3 18:32
简单好用,还安装啥

我的debian12里没有crontab,并且安装不上
作者: 笑花落半世琉璃    时间: 2024-2-3 18:37
Telegramr 发表于 2024-2-3 18:34
我的debian12里没有crontab,并且安装不上

你不会用的服务商自带的吧  这是多精简,连它都没有,重新dd下吧也没占用多少资源
作者: 似毛非毛    时间: 2024-2-3 18:44
第一次见没有crontab的debian12。。。
作者: jerry048    时间: 2024-2-3 18:46
Corn玉米?
作者: DKer    时间: 2024-2-3 18:46
直接编辑 /var/spool/cron/crontabs 目录下的文件,保存后 systemctl restart cron 重启一下服务。
作者: Telegramr    时间: 2024-2-3 18:52
笑花落半世琉璃 发表于 2024-2-3 18:32
简单好用,还安装啥

crontab -l
no crontab for admin

想试一下debian新版的,但发现不一样。

作者: Telegramr    时间: 2024-2-3 18:53
似毛非毛 发表于 2024-2-3 18:44
第一次见没有crontab的debian12。。。

真的没有
crontab -l
no crontab for admin

apt install crontab
apt install cronie
apt install cron

都提示安装不了

作者: Telegramr    时间: 2024-2-3 19:01
DKer 发表于 2024-2-3 18:46
直接编辑 /var/spool/cron/crontabs 目录下的文件,保存后 systemctl restart cron 重启一下服务。 ...

谢谢您的回复
作者: Telegramr    时间: 2024-2-3 19:03
谢谢大家的回复

apt install cron*好像安装了一堆包,不知道是不是安装上了。@DKer 的指导,重启的时候没有提示。
systemctl list-units --type=service
好像看到cron.service 服务了

作者: aru    时间: 2024-2-3 19:04
Telegramr 发表于 2024-2-3 18:53
真的没有
crontab -l
no crontab for admin

no crontab for admin
这句话的意思是admin没有设置定时任务
不是说你的机器没有cron

作者: Telegramr    时间: 2024-2-3 19:05
aru 发表于 2024-2-3 19:04
no crontab for admin
这句话的意思是admin没有设置定时任务
不是说你的机器没有cron

vi /etc/crontab

任务我是直接写进去的
作者: aru    时间: 2024-2-3 19:07
Telegramr 发表于 2024-2-3 19:05
vi /etc/crontab

任务我是直接写进去的

cron 是分用户的
执行crontab -l 是显示当前用户的定时任务
/etc/crontab 是系统的定时任务,你执行crontab -l 是不会被显示的


作者: Telegramr    时间: 2024-2-3 19:10
aru 发表于 2024-2-3 19:07
cron 是分用户的
执行crontab -l 是显示当前用户的定时任务
/etc/crontab 是系统的定时任务,你执行cront ...

谢谢您了
作者: 似毛非毛    时间: 2024-2-3 19:34
crontab -e




欢迎光临 全球主机交流论坛 (https://lilynana.eu.org/) Powered by Discuz! X3.4