I'm trying to write a bash script that I can add to the cron. What I want to do is copy a folder and attach a date (any format is ok) to the end of it and put it in a backup folder. The only part I'm stuck on is creating the date as a variable and attach it to the folder name. This is what I'm trying to do on the Red Hat.
cp dir_test /backup/dir_test_YYYY_MM_DD
After getting the date straight, I would just add this to /etc/crontab for update everyday at 6am right?
0 6 * * * /home/myscript.sh
I'm not sure if I even need a script file, can't I just put the command on the crontab itself? Thanks in advance for the. I just want to make sure I've got the right syntax and all.