-1

I scheduled a shell script in crontab it's not running when i tried manually trigger the same command which i used in crontab i am seeing below error

nohup ./home/rahul/data_script/data_backup_scripts/data_backup.sh /home/rahul/data_script/data_backup_scripts/data.param > /home/rahul/data_script/data_backup_scripts/log/nohup.$(date --iso).out
nohup: ignoring input and redirecting stderr to stdout
nohup: failed to run command ‘./home/rahul/data_script/data_backup_scripts/database_backup.sh’: No such file or directory

But i have another job which i scheduled through crontab which is running successfully and i am triggering the job as below

nohup sh /home/rahul/ddl_script/ddl_backup/ddl_backup.sh /home/rahul/ddl_script/ddl_scripts/data.param > /home/rahul/ddl_script/ddl_scripts/log/nohup.$(date --iso).out

Please help me what the problem in this when i am doing the ls on this location i can see the script located in this location and i have 777 permission over the folder and sub folders also

/home/rahul/data_script/data_backup_scripts/database_backup.sh 
1

First of all, you should remove the dot from ./home

/home/rahul/data_script/data_backup_scripts/data_backup.sh

The dot is used to refer your actual folder but when you execute something with full path you don't need it unless you have a subhome folder structure under your actual folder.

About the redirection, I recommend you to create a script that calls and executes your actual sentence. I did redirection inside the cron but it's difficult to trace and test. So create a script which encapsules your functionality and test it alone, then call it from the cron.

Finally, about the use of nohup you don't need it in cron, because it's being execute by a service so it can't be logged out during the execution.

0

The nohup command should be

nohup /home/rahul/data_script/data_backup_scripts/data_backup.sh /home/rahul/data_script/data_backup_scripts/data.param > /home/rahul/data_script/data_backup_scripts/log/nohup.$(date --iso).out &

The dot "." had as effect that you needed to be in root, "/", to run it succesfully. Also, nohup has not much sense unless you run the command in background, therefore the "&" at the end.

0

The dot in front of the /home is wrong. Delete it.

Since I was corrected about the redirections, I would still think about using an intermediate script, for this purpose of a more brief crontab file, where you have more flexibility to manage the logging, for example filtering it.

  • Redirections work in crontab. – Kusalananda Feb 24 '18 at 9:27
  • @Kusalananda: OK, I take your word for granted. – user unknown Feb 24 '18 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.