WHM Crontab and Folder Renaming to current date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting WHM Crontab and Folder Renaming to current date
# 1  
Old 03-18-2013
WHM Crontab and Folder Renaming to current date

Hello,

i am trying to rename a folder named 'cpbackup' to current date in our WHM Root via setting up a cronetab entry. but the folder does not get renamed on the scheduled time Smilie

Code:
*/1 * * * * timestamp=$(date +%m%d%Y);/bin/mv /ac_backups/cpbackup /ac_backups/$timestamp

# 2  
Old 03-18-2013
What is your schedule?
When I enter */1 * * * *, I get /1 Parameter error? here: CronBuddy - a crontab sandbox
# 3  
Old 03-18-2013
Quote:
Originally Posted by Jotne
What is your schedule?
When I enter */1 * * * *, I get /1 Parameter error?
Thanks for the handi little tool.
i changed it to */2 from */1. But the result is same. folder does not get renamed Smilie
# 4  
Old 03-18-2013
did you try with sh?

Code:
*/1 * * * * sh -c '/bin/mv /ac_backups/cpbackup /ac_backups/`date +%m%d%Y`'

# 5  
Old 03-18-2013
Quote:
Originally Posted by busyboy
did you try with sh?

Code:
*/1 * * * * sh -c '/bin/mv /ac_backups/cpbackup /ac_backups/`date +%m%d%Y`'

Smilie doesn't work

Code:
*/2 * * * * sh -c '/bin/mv /ac_backups/cpbackup /ac_backups/`date +%m%d%Y`'

---------- Post updated at 04:22 AM ---------- Previous update was at 04:12 AM ----------

but if i issue this on the bash shell it works!!
Code:
/bin/mv /ac_backups/cpbackup /ac_backups/`date +%m%d%Y`

---------- Post updated at 04:46 AM ---------- Previous update was at 04:22 AM ----------

this also works

Code:
*/2 * * * * sh -c '/bin/mv /ac_backups/cpbackup /ac_backups/test'


Last edited by kandyjet; 03-18-2013 at 06:18 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

2. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies

3. UNIX for Dummies Questions & Answers

Renaming files in a folder

Hi, I have 1000 *.txt files in a folder and I would like to rename them data1.txt through data1000.txt. The order does not matter or the names of the initial input files. How would I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

4. UNIX for Dummies Questions & Answers

Renaming files in a folder

Hi, Hope someone can help... I'm pretty much new to unix and can only do basic commands. I have an issue where by every day I need to schedule a job to look in a folder with a name format of .IP. will be different each day (when the day is over the folder extension changes), and rename any... (5 Replies)
Discussion started by: Harsharan
5 Replies

5. Shell Programming and Scripting

Help with renaming files in folder

Hello, I want to rename more than 100 files. These files have "?" in there existing file name but I want to rename files to there first part before "?" token. I have tried using for loop but it isn't working so help following is the sample filename and for loop that am trying to use: example of... (3 Replies)
Discussion started by: ls_lrta
3 Replies

6. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

7. Shell Programming and Scripting

renaming files in a folder

I splited a file into parts, then i wrote a script to convert the format of the file names to this: part1.dat part2.dat but I wonder why part.dat is also created knowing that the k variable starts from 1 rm -f part* $(split -b $1 file.1 part_) set k = 1 for i in $(ls part_*) do mv -f... (1 Reply)
Discussion started by: saman_glorious
1 Replies

8. UNIX for Advanced & Expert Users

Renaming all files in a folder

Guys, i need to replace a particular pattern in lots of files in a folder with another pattern . Is there any command line script I can use to do the functionality. Eg: aalex > ls green_1234_colour.max red_1234_pen.max yellow1234flower.max Need to replace the 1234 in the file name with 9876... (4 Replies)
Discussion started by: appualex
4 Replies

9. Shell Programming and Scripting

Renaming of multiple files with current date

Hi, I have a fixed 4 files in each different directory. The total 17 directories are there each one having 4 files inside it. I need rename all of them with current date. The files formates will be as below: Folder1: abc_NOR_xyz_ddmmyyyy.txt abc_NOR_ghij_ddmmyyyy.txt Folder2:... (5 Replies)
Discussion started by: rjanardhan83
5 Replies

10. Shell Programming and Scripting

Finding files older than the current date and time and renaming and moving

Hi, I have a very urgent requirement here. I have to find all files in the specified directory but not in the sub directories(The directory name is stored in a variable) which are older than the current date as well as current time and rename it as filename_yyyymmddhhmmss.ext and move it into a... (7 Replies)
Discussion started by: ragavhere
7 Replies
Login or Register to Ask a Question