-1

Below I have attached/included what I get when I type "crontab -l" I have run through the extremely old VI-Editor commands, and edited this with crontab -e.

I have used THIS QUESTION'S ANSWERS - but this has not solved the problem completely. I am not new to programming, but I don't know what is expected by "Stack Overflow" experienced people. Please click the link above to see what was suggested. I have followed the directions, but this hasn't got my CRON job to run... I have asked two other questions (attempting to use Java Servlets) about getting this line of Java Code to be called once a day. I need a single line of Java Code to run each day at 11:15 AM, and it will take about an hour to complete. It will not make any calls to Google Cloud Services other than to GSUTIL to do some copying of files to storage buckets.

If anybody knows about CRON jobs on GCS, which I did 20 years ago - please read the output I've attached, and explain how I could get these two scripts to execute:

# This runs an hour of Chinese & Spanish Translation jobs
java -cp /home/rtorello75/etc/Torello.jar Torello.GCS.Main.DispatchCRON

# This is just my "feeble minded attempt" to make this work.
# It produces a "TEST.txt" file with a timestamp in my ~/home directory
java -cp /home/rtorello75/etc/Torello.jar Torello.GCS.CRON.Test

The first is mine primary code module, the 2nd "Torello.GCS.CRON.Test" just dumps a test-string to a test file @ (obviously) 5:12 PM, which it is right now. That didn't actually happen...

Any help? I'm trying to get a CRON job to run/execute.

rtorello75@dispatch-cron:~$ crontab -l
# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
15 11 * * * java -cp /home/rtorello75/etc/Torello.jar Torello.GCS.Main.DispatchCRON 
12 17 * * * java -cp /home/rtorello75/etc/Torello.jar Torello.GCS.CRON.Test  
# m h  dom mon dow   command

2 Answers2

2

Firstly : to know what SO people need in order to help you, pretend you're us and know nothing about the context of this question. Basically, SO is not a discussion forum so back and forth can be a pain, you want to provide as much info as possible. You running this in a vm or a GKE job?

Secondly: Short of that, the best I can answer is to simplify the problem: Java is a complex command so at least check whether it is the problem, or your cron tab, or even your cron setup. Use one of the many online crontab parsers to confirm that your schedule string in tab file is correct, then use a simple command like ls or cat instead of Java.

Oliver
  • 27,510
  • 9
  • 72
  • 103
1

Your cron tab looks okay. Besides that and that you haven't provided any Java code, stacktrace or similar, what I can say is that this is not going to run in the Cloud Shell.

In one of the answers you have linked, it is already said that Cloud Shell is meant to be used in an interactive way. Non-interactive versions will be terminated, which means that your cronjob may or may not execute.

Your best option here, is as suggested by other user, which is, basically, moving this task to an instance in Compute Engine. There is a really useful quickstart here to help you begin with this.

Mangu
  • 3,160
  • 2
  • 25
  • 42