Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Newbie Cronjob issue on CentOS

Posted on 2009-12-22
17
Medium Priority
?
493 Views
Last Modified: 2013-12-15
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
Comment
Question by:melwong
  • 5
  • 4
  • 3
  • +2
17 Comments
 
LVL 7

Expert Comment

by:hemmi
ID: 26103246
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
 
LVL 40

Expert Comment

by:omarfarid
ID: 26103302
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
 

Author Comment

by:melwong
ID: 26103338
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 7

Expert Comment

by:hemmi
ID: 26103356
vi is complex, use nano and you will understand from the screen
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 26103395
0
 
LVL 10

Expert Comment

by:nabeelmoidu
ID: 26103582
if ur done with the editing
just hit
ZZ

0
 

Author Comment

by:melwong
ID: 26103609
ok, how do u press "M-A" to Append? see my image
0
 
LVL 4

Expert Comment

by:maysara
ID: 26103616
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
 

Author Comment

by:melwong
ID: 26103618
do you guys even look at my image attached here? when i enter ZZ, the cron list shows ZZ.
0
 
LVL 4

Accepted Solution

by:
maysara earned 300 total points
ID: 26103625
the M in nano refers to using ALT, so ALT+A to append
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 26103636
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
 

Author Closing Comment

by:melwong
ID: 31668908
N/a
0
 
LVL 10

Expert Comment

by:nabeelmoidu
ID: 26103654
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
 
LVL 7

Expert Comment

by:hemmi
ID: 26103662
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
 

Author Comment

by:melwong
ID: 26117468
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
 
LVL 4

Expert Comment

by:maysara
ID: 26118772
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
 
LVL 7

Expert Comment

by:hemmi
ID: 26118807
The first line should read
#!/bin/sh
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question