LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-02-2018, 12:04 PM   #1
Gerald_john
LQ Newbie
 
Registered: Feb 2018
Posts: 8
Blog Entries: 1

Rep: Reputation: Disabled
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 -
 
Old 03-02-2018, 12:12 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,054
Blog Entries: 13

Rep: Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501Reputation: 3501
Why can't you just edit you crontab file directly?
 
Old 03-02-2018, 01:13 PM   #3
Gerald_john
LQ Newbie
 
Registered: Feb 2018
Posts: 8

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 03-02-2018, 01:19 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
In sed expression you used #/ as delimiter but it has to be one char, ie with /
Code:
sed 's/_20480/_40960/'
 
Old 03-04-2018, 01:05 AM   #5
BudiKusasi
Member
 
Registered: Apr 2017
Posts: 54

Rep: Reputation: Disabled
Code:
crontab -l | sed -r 's/(ulimit_n\w+?status_)20480\.sh/\140960/g'
 
Old 03-08-2018, 11:23 AM   #6
Gerald_john
LQ Newbie
 
Registered: Feb 2018
Posts: 8

Original Poster
Blog Entries: 1

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

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bulk rename all 'filename.mp3?NonsenseString' to 'filename.mp3' iwtbf Linux - Newbie 4 08-07-2017 06:12 PM
CP question - Grab file name from first argument and rename that to the same filename.bak layala23 Linux - Newbie 14 10-31-2016 01:20 AM
Rename rar file based on filename contained in it rahlquist Linux - Newbie 4 09-03-2013 09:18 PM
[SOLVED] bash: how to replace symbols inside the file with filename deswarf Linux - Newbie 2 01-26-2012 04:55 AM
Filename rename jarod_123 Programming 4 03-21-2006 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration