LinuxQuestions.org
Visit Jeremy's Blog.
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 12-28-2023, 12:13 PM   #1
jt1122
Member
 
Registered: Apr 2021
Posts: 146

Rep: Reputation: Disabled
colourize crontab -l


with
Code:
crontab -l
comments are shown with an ugly yellow background.

can the output colours be customized?

Thanks
 
Old 12-28-2023, 12:57 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,195

Rep: Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952
Quote:
Originally Posted by jt1122 View Post
with
Code:
crontab -l
comments are shown with an ugly yellow background.

can the output colours be customized?

Thanks
Almost everything can be customized, if one is willing to work at researching how.
I might start with saying that you can STRIP color by filtering through something that does not color. Example:
Code:
crontab -l | cat
For more than that we might need to know what shell you are using, in what terminal program, under what version and release of which distribution of Linux, and a few other details.
 
Old 12-29-2023, 08:00 AM   #3
jt1122
Member
 
Registered: Apr 2021
Posts: 146

Original Poster
Rep: Reputation: Disabled
Thanks.

Using Debian Testing + bash 5.2.21(1) .
 
Old 12-29-2023, 01:57 PM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,195

Rep: Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952
That narrows it down to one of (I think) 14 terminal emulation terminal programs depending upon what GUI (if any) you might have chosen to install. For each there are also multiple settings and environment variables that might impact colors in display. Several of them allow you to specifically set the colors, hue and saturation, for multiple classes of foreground, background highlighting, bold, etc. Have you looked for settings information in the man page for your specific terminal program?
 
Old 01-02-2024, 07:25 AM   #5
morfik
LQ Newbie
 
Registered: Nov 2013
Location: Europe/Poland
Distribution: Debian Sid
Posts: 3

Rep: Reputation: 0
It looks like it's the feature of crontab:

Quote:
Originally Posted by man crontab
The -l option causes the current crontab to be displayed on standard output. When the output is a tty, comment lines are colored to distinguish them from action lines.
How to prevent crontab from displaying the colored comments?
 
Old 01-02-2024, 10:09 AM   #6
jt1122
Member
 
Registered: Apr 2021
Posts: 146

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by morfik View Post
How to prevent crontab from displaying the colored comments?
...or customize the colour being used for comments.
 
Old 01-02-2024, 02:13 PM   #7
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,195

Rep: Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952
Quote:
Originally Posted by morfik View Post
It looks like it's the feature of crontab:



How to prevent crontab from displaying the colored comments?
See #2. Pipe through cat (or anything else) and the STDOUT for the command is the pipe, not a tty, so it does not color.

Also, if you change the terminal type to one that does not support color for that command you will get no color.

If it is the same ls that I use, try
Code:
ls --color=never

Last edited by wpeckham; 01-02-2024 at 02:15 PM.
 
Old 01-03-2024, 03:19 AM   #8
morfik
LQ Newbie
 
Registered: Nov 2013
Location: Europe/Poland
Distribution: Debian Sid
Posts: 3

Rep: Reputation: 0
I think I'll wait for the support of the NO_COLOR var in cron:

Quote:
Release 1.5.7

...
crontab: switch off colors if NO_COLOR is set

Last edited by morfik; 01-03-2024 at 03:21 AM.
 
Old 01-03-2024, 06:17 PM   #9
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486
Quote:
Originally Posted by morfik View Post
It looks like it's the feature of crontab:



How to prevent crontab from displaying the colored comments?
use something like
Code:
crontab -l | grep -v "#"
since all the comments should have the '#' at the beginning of the line
 
Old 01-05-2024, 08:45 AM   #10
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Distribution: Mint/MATE
Posts: 3,040

Rep: Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313Reputation: 1313
ITYM
Code:
crontab -l | grep -v "^#"
to skip just the crontab comments (and not shell commands with a #).
But I prefer to only prevent the coloring, as already suggested:
Code:
crontab -l | cat
 
Old 01-05-2024, 10:52 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,311

Rep: Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985Reputation: 7985
Quote:
Originally Posted by morfik View Post
It looks like it's the feature of crontab:
Code:
The -l option causes the current crontab to be displayed on standard output. When the output is a tty, comment lines are colored to distinguish them from action lines.
How to prevent crontab from displaying the colored comments?
You need to read a bit further:
Quote:
When listing a crontab on a terminal the output will be colorized
unless an environment variable NO_COLOR is set.
But probably it depends on the exact version of the tool. Using pipe (like crontab -l | cat) will solve it too.
 
Old 01-05-2024, 02:32 PM   #12
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,195

Rep: Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952Reputation: 2952
Note that environment variables CAN be set IN the crontab file almost as if it were a script, and they will exist and have effect ONLY during the cron run that uses that crontab file and ONLY for that crontab file's processes.
 
Old 01-06-2024, 11:42 AM   #13
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,850

Rep: Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553
Quote:
Originally Posted by jt1122 View Post
Thanks.

Using Debian Testing + bash 5.2.21(1) .
Seems like this is a Debianism. For what it's worth, "crontab -l" produces simple text output on OpenSUSE; no colored comments. And no environment variables needed either.

Unless you really need to see the comments, perhaps you could define an alias that executes "crontab -l | grep -v '#'" or piping the output to cat as computersavvy suggested.
 
  


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
DIff B/w Crontab -l & crontab -e Tareq9959 Linux - Newbie 2 05-14-2013 08:27 AM
linux crontab vs unix crontab ytd Linux - General 2 08-09-2009 05:07 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
man crontab(5) vs crontab(1) Canis Polaris Linux - Newbie 2 06-04-2008 04:03 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

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

All times are GMT -5. The time now is 05:05 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
Open Source Consulting | Domain Registration