• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 495
  • Last Modified:

Newbie Cronjob issue on CentOS

I am VERY new to cronjobs. I access my shell and wanted to do cronjob.

After i type crontab -e, i added one new line of cronjob to do. Then the attached image screen appear asking me if i want to write to the file /tml/crontab.XXXXsomethingsomething.

What is the next step i should take? send M-A Append command? How you type M-A?
cronjob-issue.JPG
0
melwong
Asked:
melwong
  • 5
  • 4
  • 3
  • +2
1 Solution
 
hemmiCommented:
When you start "crontab -e" you end up in an editor called vi.
See "man vi" for information on vi.
If you want to use a different editor you must first do a
export EDITOR=editor_of_your_choice
e.g.
export EDITOR=nano
Then crontab -e will start another editor.
For this simple type of editing nano is a good choice. The few necessary commands are explained in the editor window. Or simply play with nano beforehand.
0
 
omarfaridCommented:
here some links that help in understanding and using crontab

http://www.adminschoice.com/docs/crontab.htm
http://www.tutorial5.com/content/view/95/51/
0
 
melwongAuthor Commented:
can u just tell me how to use VI? i understand crontab, i just don't understand how to use VI with crontab as shown in my image.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
hemmiCommented:
vi is complex, use nano and you will understand from the screen
0
 
nabeelmoiduCommented:
if ur done with the editing
just hit
ZZ

0
 
melwongAuthor Commented:
ok, how do u press "M-A" to Append? see my image
0
 
maysaraCommented:
in that screen, just hit enter.., and then exit it

nano is very simple, stick to it... do your edits, use ctrl+X to EXIT, then Y to save ... you should be done.
0
 
melwongAuthor Commented:
do you guys even look at my image attached here? when i enter ZZ, the cron list shows ZZ.
0
 
maysaraCommented:
the M in nano refers to using ALT, so ALT+A to append
0
 
omarfaridCommented:
why don't you do the following:

1- run from command line

crontab -l > mycron

2- edit the file mycron with any text editor of your choice (e.g. vi :) ) to add the required schedule, then save and exit from text editor

3- run the command

crontab mycron

4- verify that your crotab jobs are ok

crontab -l

0
 
melwongAuthor Commented:
N/a
0
 
nabeelmoiduCommented:
sorry, I thought you were using VI for crontab. In that screenshot you are using nano.


At that screen just hit Enter as maysara mentioned.
0
 
hemmiCommented:
He's only fighting with the editor. Taht won't help!
And he's still using vi instead of nano. nano is probably by far too easy form him.
In case your in insert mode in vi, type
ESC :wq
In case not in insert mode, just type
:wq

Then use nano as described above to check what has been saved and modify to your liking!
0
 
melwongAuthor Commented:
ok,

I manage to put in the cronjob, but now I'm getting this error when the cron is executed.

/home/uplayuwi/public_html/WEB-INF/classes/rank_alert.sh: line 1: ?cd: command not found
/home/uplayuwi/public_html/WEB-INF/classes/rank_alert.sh: line 3: java: command not found
0
 
maysaraCommented:
well, you'r script is apparently broken (at least when run in cron), you need to understand that the cron job is executed in a shell where bashrc is not run, nor the user profile, so the environment is not identical to that of your login shell ... you either need to handle this in your script (i.e, setting full pathes where needed, setting environment variables) or manually mimic login shells (by manually from script running the rc's and profile ..etc)
0
 
hemmiCommented:
The first line should read
#!/bin/sh
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now