[英]how to run a bash script in background automatically?
I need to write a bash script that automatically deletes temp files, and runs in the background each day.我需要编写一个 bash 脚本来自动删除临时文件,并每天在后台运行。
#!/bin/bash
while true;
do
rm /home/c/temp/*
sleep 24h
done
but it doesn't work但它不起作用
write a shell script写一个shell脚本
rm /home/c/temp/*
and add a line in the crontab并在 crontab 中添加一行
crontab -e
add the line添加行
0 12 * * * path/to/script
It will execute you script every day at midday.它会在每天中午执行您的脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.