LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Rename filename inside the crontab file (https://www.linuxquestions.org/questions/linux-newbie-8/rename-filename-inside-the-crontab-file-4175624808/)

Gerald_john 03-02-2018 12:04 PM

Rename filename inside the crontab file
 
Hi Team,

i have below file is my crontab,

00 * * * * /home/@@@@/ulimit_nofile_status_20480.sh >> /export/####/$$$$$/ulimit_nofile_status.txt

00 * * * * /home/@@@@/ulimit_nproc_status_20480.sh >> /export/####/%%%%/ulimit_nproc_status.txt

i want to change the file name (ulimit_nofile_status_20480.sh and ulimit_nproc_status_20480.sh) to (ulimit_nofile_status_40960.sh and ulimit_nproc_status_40960.sh) these are file names.

I want to rename 20480 to 40960

Had tried below commands but did not work for me.
1) crontab -l | sed 's#/_20480\.#/40960.#' | crontab -
2) crontab -l | sed 's/\<_20480\>/40960/' | crontab -

rtmistler 03-02-2018 12:12 PM

Why can't you just edit you crontab file directly?

Gerald_john 03-02-2018 01:13 PM

i have more than 50 server and i can't do it manually on all the server. so looking out for any command or script which can help me out

keefaz 03-02-2018 01:19 PM

In sed expression you used #/ as delimiter but it has to be one char, ie with /
Code:

sed 's/_20480/_40960/'

BudiKusasi 03-04-2018 01:05 AM

Code:

crontab -l | sed -r 's/(ulimit_n\w+?status_)20480\.sh/\140960/g'

Gerald_john 03-08-2018 11:23 AM

Thanks team,
i was able to rename the file name by the below command:

ssh $line "crontab -l | sed 's/20480/40960/' | crontab -"


All times are GMT -5. The time now is 11:58 AM.