我需要编写一个 bash 脚本,自动删除临时文件,并每天在后台运行。
#!/bin/bash
while true;
do
rm /home/c/temp/*
sleep 24h
done
但是不起作用
最佳答案
编写shell脚本
rm /home/c/temp/*
并在 crontab 中添加一行
crontab -e
添加行
0 12 * * * path/to/script
它将在每天中午执行您的脚本。
关于linux - 如何在后台自动运行bash脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36358300/