简体   繁体   中英

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.

#!/bin/bash  
while true;  
do      
    rm  /home/c/temp/*
    sleep 24h
done

but it doesn't work

write a shell script

rm /home/c/temp/*

and add a line in the crontab

crontab -e

add the line

0 12 * * * path/to/script

It will execute you script every day at midday.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM