I am a novice ... I will just get that right up front. I have a simple Ubuntu 20.04 LTS server used only as a minecraft server.
The crontab is giving me some problems
*/10 * * * * screen -S minecraft -p 0 -X stuff "save-all^M"
@reboot /home/minecraft/startserver.sh
@daily find /home/minecraft/backup/* -mtime +6 -type f -delete
@daily zip -9 -r --exclude=*backup* --exclude=*web* --exclude=*crash-reports* --exclude=*lost+found* /home/minecraft/backup/$(date +"%Y.%m.%d %I.%M %P").zip /home/minecraft
The first line works, but the @daily and @reboot do not work at all. ALL the commands work from the terminal without error.
Please help me understand this, I am not experienced with linux and I am trying to figure this out. I am aware that some people might think this would be better handled with systemd, but I am too new to figure that out yet and I don't want to install a script I can't repair.
Why is the crontab failing these lines? I don't think it is permissions. Please help me debug this
Thanks for your time
EDIT: OK, after digging around, the issue with the startserver script was within the script itself and not the crontab. I found out I need to have the -d
flag for the screen command in crontab.
The zip command is working, but I can't figure out what escape code to use to add spaces in the date backup/$(date +"\%Y.\%m.\%d \%I.\%M \%P").zip
Using a slash \
or using " "
do not work. If anyone knows how to escape a space with creating zip files, please let me know.
I was told in the comments to use the proper format for editing the post. I don't know what that means, this is my first post.