0

Below is my Crontab:

*/5 * * * * /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"

i am scheduling but its not running

  • 1
    Does the command work if you run it manually? Double check that to make sure it's the cron job that's failing, and not your command. How do you know it's not running? Usually logs will tell you if the cron ran or not, popular cron log locations are `/var/log/cron`, `/var/log/messages`, and `/var/log/syslog`. – drewyupdrew Apr 14 '16 at 14:33

2 Answers2

1

You have to use full paths in crontab, since it does not have same value of $PATH as your shell (ie use full path for nohup, sqoop )

calvix
  • 173
  • 1
  • 2
  • 12
0

This could be because your not in the same execution context. Depending on which shell you are running (adapt my old-school .kshrc), you might need to prefix the command with a source /home/myuser/.kshrc, like below:

*/5 * * * * source /home/myuser/.kshrc ; /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"

If I may, this could also look simpler to everybody if your command could be embedded in a small script. This could avoid this possibly misleading nohup you have... then if script is mycommand.sh:

*/5 * * * * source /home/myuser/.kshrc ; /home/myuser/mycommand.sh

(being given you did a chmod u+x /home/myuser/mycommand.sh to grant execution rights).

J. Chomel
  • 8,193
  • 15
  • 41
  • 69