crontab 提取 cron 表达式

use*_*597 2 bash shell cron

当我执行crontab -l 时,我可以看到我所有的工作

56 12 3 2 * /usr/bin/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "https://server6.mp3quran.net/akdr/001.mp3" "Office Ustairs speaker" >> .error.log  2>&1 # Al-Fatiha - [Verses 7]
56 12 * * * /files/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "https://server6.mp3quran.net/akdr/001.mp3" "Office Ustairs speaker" >> .error.log  2>&1 # Al-Fatiha - [Verses 7]
31 18 3 2 * /usr/bin/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "/static/media/azan5.mp3" "Office Ustairs speaker" # prayer_isha
Run Code Online (Sandbox Code Playgroud)

无论如何,我只能提取“表达式”吗?

我需要这样出去......

56 12 3 2 * 
56 12 * * * 
31 18 3 2 * 
Run Code Online (Sandbox Code Playgroud)

P..*_*... 6

这应该有效:

crontab -l |awk '{NF=5}1'
Run Code Online (Sandbox Code Playgroud)

在这里,您告诉 awk 每行中的字段数为 5 ,这会导致打印前五列。

  • 请参阅https://unix.stackexchange.com/questions/63891/what-is-the-meaning-of-1-at-the-end-of-awk-script (2认同)