Crontab -e not working. but crontab -l works - cron

I use an Amazon Lightsail Lamp Server.
I am trying to edit a CRON job, which I setup previously using crontab -e but the editor keeps returning 964 and a blank page.
crontab -l shows the content of the file.
Any tips ?

Solved. The issue was with the text editor used by my terminal.
These were the steps I took :
export EDITOR=/bin/nano
source ~/.bashrc
echo $EDITOR
export VISUAL="/bin/nano"

Related

Using Cron tabs to open localhost on a web browser

I am trying to get my PI, which is running rasbian, to automatically run a bash command whenever the pi is booted. The ultimate goal is to open the localhost web page.
I ran
crontab -e
to open my crontab, and added this to the end of the file:
#reboot chromium-browser --kiosk localhost
but when I reboot the pi, nothing appears to happen. I then added this to test to see if crontab was even running or if I had formatting wrong:
#reboot cd && sudo touch sucess
But it executed exactly as expected
What am I missing?
EDIT 1: I did try doing this but it still didn't execute:
#reboot cd && chromium-browser --kiosk localhost
EDIT 2: I also saw an article suggesting that cron cannot find bash command locations, so I tried this as well, also to no avail:
#reboot cd && /bin/chromium-browser --kiosk localhost
EDIT 3: I also attempted to put the same command in root's crontab instead by doing sudo crontab -eBut that didn't work either

UNIX : Editing system crontab (/etc/crontab) and restarting cron services after edit

I want to edit system cron tab (/etc/crontab). I read that crontab -e is the best way to edit crontab and you need not restart cron services if you edit this way. However I am not able to edit /etc/crontab using crontab -e (this command edits the crontab associated with the user, not system crontab). So is there any better way of editing /etc/crontab (other than using VI editor- which I am doing now). Do I need to restart cron services if I edit /etc/crontab using VI edior?
There are two ways of cronjobs, one is by editing /etc/crontab and sending a SIGHUP the cron daemon. The other way is to use crontab -e to edit
a crontab entry, which is done for the current user or the one mentioned with -u. The -u option can only be used by root. The crontabs
created this way can be found in the directory
/var/spool/cron/crontabs/
and are named after the user with which uid the jobs will be started. In this case you don't need to SIGHUP cron, a normal user can't do this anyway.
Note: The syntax is slightly different to /etc/crontab: You can't enter an other user name to execute the cronjob.
You could do something like this
echo "0 23 * * * yum -y update > /dev/null 2>&1" >> /var/spool/cron/root
Then verify with
crontab -l

run a screen after reboot

i tried to google but had no luck perhaps because i am not sure on the terms to look for. basically im trying to auto run a screen after the system reboots. i tried crontab but it seems that i cannot execute the jar file unless im in the directory.
something like
crontab -e:
#reboot screen -d -m -S ModBot java -jar /home/themoduser/modbotfiles/ModBot.jar start
im not sure if that is a correct method or if trying to use a .sh script:
cd /home/themoduser/modbotfiles/
screen -d -m -S ts3bot java -jar ModBot.jar
and in crontab
#reboot /home/themoduser/modbotfiles/ModBot_startscript.sh start

crontab -e issue on sun solaris fresh installation

I'm doing server migration in sun solaris OS. And I have to migrate crontabs also with that. New server have fresh installation of solaris. In usual way while I type crontab -l it shows the existing cron content.
But while I type crontab -e it fail to load the editor. How can I overcome this issue?
This can be fixed by exporting editor variable with value vi. So run following command and then run crontab -e
export EDITOR=vi
crontab -e

Write from Shellscript to file when running the script from crontab

What I am trying and tried to do:
I've written a Shellscript which should write some logs into a logfile. Something like:
echo "downloaded header" >> log
I also tried with cat instead of echo and I've given full permissions to the log so it should be accessible for anyone. If I start the script from the command line everything works fine and the entries are made as expected.
It didn't matter if I gave the full path to the logfile or not, I tried both.
The Problem:
If I run the script from crontab and yes It has to work with crontab, nothing is written into my log. So the echo "xy" >> log doesn't work, neither does the cat.
Any Ideas? Thanks in advance.
try this solution:
cat cronjob
* * * * * echo "downloaded header" >> /path/to/log
Then:
chmod +x cronjob
chmod +x script.sh
/etc/init.d/crond start #redhat based servers like centos
/etc/init.d/cron start #debian based servers like ubuntu
crontab cronjob
Try redirecting to the log file with full path
echo "downloaded header" >> $HOME/Log_dir/log ## just an example

Resources