-3

Hi when am submitting a shell script using cronjob am facing the bellow issue.

I have attached the backup help command.

* * * * * ankush /home/ankush/test.sh
backup: Unrecognized operation 'codebak'; type 'backup help' for list

backup help list


backup: Commands are:
adddump         add dump schedule
addhost         add host to config
addvolentry     add a new volume entry
addvolset       create a new volume set
apropos         search by help text
dbverify        check ubik database integrity
deldump         delete dump schedule
deletedump      delete dumps from the database
delhost         delete host to config
delvolentry     delete a volume set sub-entry
delvolset       delete a volume set
diskrestore     restore partition
dump            start dump
dumpinfo        provide information about a dump in the database
help            get help on commands
interactive     enter interactive mode
jobs            list running jobs
kill            kill running job
labeltape       label a tape
listdumps       list dump schedules
listhosts       list config hosts
listvolsets     list volume sets
quit            leave the program
readlabel       read the label on tape
restoredb       restore backup database
savedb          save backup database
scantape        dump information recovery from tape
setexp          set/clear dump expiration dates
status          get tape coordinator status
version         show version
volinfo         query the backup database
volrestore      restore volume
volsetrestore   restore a set of volumes

Please find the flow of commands from my console.

ankush@hn0-ank-d:~$ more test_script.sh
echo "test"
ankush@hn0-ank-d:~$ * * * * * ankush /home/ankush/test_script.sh
backup: Unrecognized operation 'codebak'; type 'backup help' for list
ankush@hn0-ank-d:~$

when I first ran the code, it asked me to install sudo apt install openafs-client. I went ahead and installed it.

What could be the reason?

5
  • 1
    Can you please post the contents of your test.sh script? Also do you see this output in stdout after setting the job? Additionally, I'm not sure what the impact of your crontab format is but I believe you are telling it either to "Never stop running this job" or "Never run this job" because you haven't selected a time. Try: */5 * * * * ankush /home/ankush/test.sh To run every 5 minutes.
    – jesse_b
    Commented Aug 14, 2017 at 18:27
  • 1
    Are you editing the system crontab or a user's crontab? The system crontab has the format that you use while a user's crontab doesn't have the sixth field (the user name).
    – Kusalananda
    Commented Aug 14, 2017 at 18:42
  • I want to run this job every minute. Test.sh Even if I just use a echo "hello" inside the script am getting the same error. Commented Aug 14, 2017 at 18:42
  • What error message do you get? Is "backup: Unrecognized operation 'codebak'; type 'backup help' for list" Really the error message you get when your script only contains echo "hello"? Again, please post the contents of test.sh and explain when you get this error message. Is it when you try to exit from crontab? Is it after you exit crontab and the job starts? When you exit crontab does it say crontab: no changes made to crontab or crontab: installing new crontab?
    – jesse_b
    Commented Aug 14, 2017 at 18:44
  • when I first ran the code. it asked me to install sudo apt install openafs-client. I went ahead and installed it. After that I just ran the listed lines it is giving an error. I tried to google it but no information on that. Commented Aug 14, 2017 at 19:08

2 Answers 2

6

It looks as if you are trying to enter a crontab job specification directly on the command line. That won't work.

To add a crontab job, use

$ crontab -e

to edit your crontab. Add the job specification there, save and exit the editor.

The job specification that you have,

* * * * * ankush /home/ankush/test_script.sh

looks as a system crontab job. That is, it has an extra sixth field which is the username (see your crontab manual, man 5 crontab). Your own private crontab should not have this.

I believe this is what you should have in your crontab:

* * * * * /home/ankush/test_script.sh

This will invoke the script /home/ankush/test_script.sh once a minute. Any output or error from this job ought to get emailed to you.


The cryptic error message that you get comes from trying to execute the command * * * (etc.) in the shell. It is totally unrelated to cron and your script. The shell just expands the * to all the files in the current directory and tries to run that as a command. Apparently, the first * expands to backup codebak and it just happens that backup is the name of some command that does not understand what codebak means.

1
  • Thanks It solved the problem. Have accepted your answer. Commented Aug 14, 2017 at 19:54
0

You made a many common cron mistakes. Some of them:

  1. Wrong command syntax in the crontab file
  2. Wrong path to your script file
  3. No execute permissions on your script file
  4. Using undeclared variables in your profile

Always check syntax of your command, look at cron logs, check permission for files and directories.

You must log in to answer this question.

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