J2L6j

                -- do not even try to persuade me, I have changed..
                -- but the world has not changed Orm.
                   It is ruled by those who got the Stones.
                   
                The Snow Queen: Magic Of The Ice Mirror, 2014, 17:59
                
# 28 feb 2018:

  $ crontab -e
  no crontab for virtu - using an empty one

  Select an editor.  To change later, run 'select-editor'.
    1. /bin/ed
    2. /usr/bin/vim.tiny

  Choose 1-2 []:
  ..

Cache rare messages for later use:

  " To change later, run 'select-editor'. "

                
# PROBLEM FOR 27 feb. 2019

1. Allow VT8 (virtual terminal 8) on "Gateway" virtual computer.

2. Show cron messages to VT8

3. Cron must show message "Hello from Cron $COUNTER" every minute, where
   COUNTER shows how many times crontab was applied.


# SOLUTION

Edit console configuration:

  # nano /etc/default/console-setup

file console-setup
  
  # CONFIGURATION FILE FOR SETUPCON

  # Consult the console-setup(5) manual page.

  ACTIVE_CONSOLES="/dev/tty[1-8]"

  CHARMAP="UTF-8"

  CODESET="Lat15"
  FONTFACE="TerminusBold"
  FONTSIZE="10x20"
  SCREEN_WIDTH="80"

  VIDEOMODE=

EOF

  # reboot
  

Create file to store persistent data

  # touch /root/count

Edit crontab

  # crontab -e
  * * * * * sh -c /root/counter > /dev/tty8

Create file /root/counter

file counter

  #!/bin/bash

  for x in `cat count` ; do echo 0 > /dev/null ; done
  x=`expr $x \+ 1`
  printf "%d Echoed\n" $x
  echo $x > $HOME/count

EOF

NOTE: Switch ALT+8 ALT+1 and back (probably some bug, black on black)
Done..


# CRON

1. Read [1] [2].

2. Understand examples from [3].

3. Check your crontab syntax with [5].

NOTE!: "Command run from a crontab do not execute within a login shell. As with ssh you can work around this by explicitly creating a login shell" [1]:

  * * * * * sh -l -c /home/user/myscript.pl
  
  -l   Make sh act as if it had been invoked as a login shell.
  
  -c   Read commands from the command_string operand instead of from the standard input.  Special parameter $0 will be set from the command_name operand and the positional parameters ($1, $2, etc.) set from the remaining argument operands.


# LINKS:

1. https://mediatemple.net/blog/news
     /complete-beginners-guide-cron-part-1/

2. https://mediatemple.net/blog/tips
    /complete-beginners-guide-cron-part-2/

3. http://www.nncron.ru/nncronlt/help/RU/working/cron-format.htm

4. http://www.microhowto.info/howto
     /persistently_set_the_value_of_an_environment_
     variable_for_all_users.html

5. Check crontab online:

      https://crontab.guru/
