-2

I recently got an VPS to experiment, I have installed Centos and is trying to see if I can setup hostbill and run it from there. The installation all worked out well but I am stumped when it comes to setting up a cron job. I need to setup the following job:

*/5 * * * * php -q /var/www/html/bill/hostbill/admin/cron.php

but I have never before done it using command line, used to do it from the comfort of cPanel. Now I did look up a bit and did the following. Logged in as root and then in the console hit crontab -e, inserted the job I wanted to run and then exit the text editor. I keep getting this error:

/bin/bash: q: command not found

shell returned 127. I am really a newbie when it comes to linux and managing a VPS could you guys help me out a bit?

Here is the full command I am using

crontab -e 

this opens nano there i type

*/5 * * * * php -q /var/www/html/bill/hostbill/admin/cron.php

then i press ctrl+o and then :!q to close nano as soon as nano closes I get the following errors in the console

no crontab for root - using an empty one
[No write since last change]
/bin/bash: q: command not found

shell returned 127

Press ENTER or type command to continue
1
  • Post the full commands you are using and the full output. What you are doing is correct; we need to work out why the error is coming up.
    – fukawi2
    Nov 14, 2013 at 5:29

1 Answer 1

3

Those commands ":!q" looks like vi commands, but in the wrong order.

The way you're doing it now, "!q" means "start a shell" (!)" and "run the command 'q'".

The reverse, ":q!" means "quit and don't save, and don't ask me to save changes, I really want to quit."

Try ":wq" to "write" then "quit".

4
  • In nano, ctrl-O (and enter) followed by ctrl-X is the usual save and exit. Nov 14, 2013 at 6:12
  • Yes, it seems like you might actually be using vi, not nano.
    – whitepaws
    Nov 14, 2013 at 6:44
  • Quite likely. However, it's really hard to tell. Nov 14, 2013 at 6:50
  • Rick Roy can try :!ps -e f instead of :!q and see if nano, or vi or vim, shows up in the process listing.
    – whitepaws
    Nov 14, 2013 at 6:55

Not the answer you're looking for? Browse other questions tagged .