Hello can anyone help me to make a script that everynight 02:00 linux automaticly empty 2 directory's? /var/www/web2/web/mahir/png /var/www/web2/web/mahir/tmp is that possible ?
Save this script as e.g. /usr/bin/emptydir.sh Code: #!/bin/bash rm -rf /var/www/web2/web/mahir/png rm -rf /var/www/web2/web/mahir/tmp Then make it executable: Code: chmod +x /usr/bin/emptydir.sh Then edit your crontab with the command: Code: crontab -e and add a line: Code: 59 23 * * * /usr/bin/emptydir.sh &> /dev/null
/usr/bin/ulyaothdelete.sh Code: #!/bin/bash rm -f /var/www/web2/web/gd-rppng/png/*.png rm -f /var/www/web2/web/gd-rppng/tmp/*.txt chmod +x /usr/bin/ulyaothdelete.sh crontab -e and i added 0 2 * * * /usr/bin/ulyaothdelete.sh &> /dev/null So now this should be ok ?
It deletes the directories. If you only want to delte the contents inside of the directories, you can use this script: Code: #!/bin/bash rm -rf /var/www/web2/web/mahir/png/* rm -rf /var/www/web2/web/mahir/tmp/*