I have gone through many answers as to how to add a crontab through terminal through one liners and came across only one single option everywhere which is {crontab -l; echo 1 * * * * /usr/bin/firefox } | crontab -Running which all I am receiving is>That's it. A promt for me to type something. and second option being(crontab -l; echo 1 * * * * /usr/bin/firefox ) | crontab -Which seems to add the cron to /var/spool/cron/crontabs/root but does not open firefox every minute, in fact it does not open at all.I read most on most answers that you should not edit the /var/spool/cron/crontabs/root or /etc/crontab files directly.Is this not supported in my system or what?An output of uname -a gave the following description of my systemLinux earth 4.9.0-kali4-amd64 #1 SMP Debian 4.9.30-2kali1 (2017-06-22) x86_64 GNU/LinuxEDIT: Following message logs are repeated often in my /var/spool/mail/mail logsFrom root@localhost.localdomain Sun Jul 09 16:01:12 2017 Return-path: < root@localhost.localdomain > Envelope-to: root@localhost.localdomain Delivery-date: Sun, 09 Jul 2017 16:01:12 +0530 Received: from root by earth with local (Exim 4.89)       (envelope-from <root@localhost.localdomain>)      id 1dU9UY-0001Ry-3A       for root@localhost.localdomain; Sun, 09 Jul 2017 16:01:06 +0530 From: root@localhost.localdomain (Cron Daemon) To: root@localhost.localdomain Subject: Cron <root@earth> /usr/bin/firefox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Cron-Env: < SHELL=/bin/sh > X-Cron-Env: < HOME=/root > X-Cron-Env: < PATH=/usr/bin:/bin > X-Cron-Env: < LOGNAME=root > Message-Id: < E1dU9UY-0001Ry-3A@earth > Date: Sun, 09 Jul 2017 16:01:06 +0530Error: GDK_BACKEND does not match available displays
Crontab addition not working
cron
Most likely your second attempt is correct, but your expectation is wrong.Let's look at it in parts:crontab -llists all existing entries for the current user's crontab. Theecho 1 * * * * /usr/bin/firefoxjust prints that line again. These two commands are then grouped together in a subshell and the common output is piped intocrontab -So the crontab is overwritten by what comes in via the standard input, which in this case is the old crontab plus the new entry.As you said it is added to the crontab file. And, assuming the cron daemon is running, the command will be executed each minute.So why aren't you seeing a firefox window each minute? - Because the conrjob runs in a different shell below the cron daemon, which doesn't have access to your X session, thus firefox will fail and report something like (firefox:22376): Gtk-WARNING **: Locale not supported by C library.    Using the fallback 'C' locale.Error: GDK_BACKEND does not match available displaysAnd terminate. How to see that error? Typically the cron daemon will try to send you a mail, see /var/spool/mail eventually.About the two forms:{ crontab -l; echo 1 * * * * /usr/bin/firefox } | crontab -would have to be written as{ crontab -l; echo 1 * * * * /usr/bin/firefox; } | crontab -(mind the extra semicolon)The difference between () and {} is that the former creates a sub-shell, whereas the later executes the commands in the same shell context. Thus variable assignments survive in one form, not in the other.