1分ごとに実行されるクローンジョブをどのように実行しますか?

1分ごとに実行されるクローンジョブをどのように実行しますか?

名前にタイムスタンプを含むディレクトリを作成しようとしています/home。 rootユーザーとして次のクローンジョブを作成しましたが、実行されませんでした。私は何が間違っていましたか?

以下は、rootユーザー権限を使用して作成したcronジョブです。

[root@bvdv-emmws01 home]# crontab -l
* * * * * /home/test.sh

以下は内容です/home/test.sh修正する:ディレクトリにフルパスを追加しました。

[root@bvdv-emmws01 home]# cat /home/test.sh 
#!/bin/bash
mkdir /home/test_$(date -d "today" +"%Y%m%d%H%M%S")

ライセンス/home/test.sh:

[root@bvdv-emmws01 home]# ls -ltr /home/test.sh
-rwxrwxrwx 1 root root 58 Dec  2 12:58 /home/test.sh

/etc/crontabファイルを更新しました。これでファイルの内容は次のようになります。

[root@bvdv-emmws01 home]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

* * * * * root /home/test.sh

状態crond daemon

[root@bvdv-emmws01 home]# service crond status
crond (pid  1910) is running...

ベストアンサー1

crontab -e作成されリストされたcrontabを使用する場合は、crontab -lこのコマンドのユーザーを指定しないでください。あなたのアイテムは次のようになります:

* * * * * /home/test.sh

または、すでに持っている行を入れることもできます/etc/crontab

man 5 crontab(システムCRONファイルの例のセクション)から:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

最後の文章に注目してください。

おすすめ記事