How to schedule a Cron Job to run a script on Linux

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • This video explains the method on how to schedule a cronjob to run a script on any Linux machine. Crontab allows users to schedule and run jobs at any given time.

Комментарии • 25

  • @user-sf9gs2pg1b
    @user-sf9gs2pg1b Год назад +1

    Best video I've seen explaining this so far. Thanks :)

  • @user-qq3ew8zg1o
    @user-qq3ew8zg1o 6 месяцев назад

    One of best video to schedule job i loved ur explanation very very nice

  • @rambabuthandu3700
    @rambabuthandu3700 7 месяцев назад

    Well explained sir

  • @gomeagle1989
    @gomeagle1989 Год назад

    Hello @AspiringArchitect.
    Thanks a lot for this video.
    I want more explaination if i want to do a crontab to restart my wildfly application every sunday of a week ? I try but... Could you help ?

  • @kondalakshmidevi698
    @kondalakshmidevi698 Год назад

    Hello sir
    I'm creating a file in vi
    It is not created file
    It's thorwing an you have new mail in /var/spool/mail/root
    Tell me sir how can I create a file in vi

    • @aspiringarchitect209
      @aspiringarchitect209  11 месяцев назад

      It seems like you're encountering an issue while trying to create a file using the vi text editor. The message "you have new mail in /var/spool/mail/root" might be unrelated to creating a file in vi and is actually indicating that you have new email messages in the root user's mailbox.
      Type the following command to create and open a new file using vi:
      vi filename
      Replace "filename" with the name you want to give to your new file.
      Press Enter.
      You will be in the vi text editor. To start typing and adding content to the file, press the "i" key. This will put vi into insert mode, allowing you to type and edit the file.
      Type or paste the content you want in the file.
      When you're done editing the file, press the "Esc" key to exit insert mode.
      To save the file and exit vi, you can type :wq and then press Enter. This command means "write" (save) and "quit" (exit).
      If you just want to save the file without exiting vi, you can use the :w command. To exit vi without saving changes, you can use the :q! command.
      Remember to replace "filename" with the actual name you want to give to your file. If you're still having issues or encountering any error messages, please provide more details about the specific problem you're facing, and I'll be happy to assist you further.

  • @chrismbah597
    @chrismbah597 Год назад

    Sir thanks for the video, I wish to ask you this question. When creating the script using the vi editor why do you not start as #! /bin/bas
    Before passing the touch command on the next line???

    • @aspiringarchitect209
      @aspiringarchitect209  11 месяцев назад

      In Unix-like operating systems, when you create a script using the vi editor (or any other text editor), you can start the script with a shebang line (also known as a hashbang or a pound-bang line), which specifies the interpreter that should be used to execute the script. The shebang line begins with #! followed by the path to the interpreter.
      For example, if you're writing a Bash script, you would typically start your script with:
      #!/bin/bash
      So, to directly address your question, if you're using the vi text editor to create a script, it's a good practice to start with the shebang line, like #!/bin/bash, before any other commands in the script. This ensures that when you make the script executable and run it, the correct interpreter (in this case, Bash) will be used.

  • @Islamic-channel995
    @Islamic-channel995 7 месяцев назад

    Thanks

  • @parthasaradhi2061
    @parthasaradhi2061 2 года назад +1

    For every 30sec i need to run the command...
    */.30 * * * * is this correct command

    • @aspiringarchitect209
      @aspiringarchitect209  2 года назад

      Cron does not go down to sub-minute resolutions, ie.. Cron job cannot be used to schedule a job in seconds interval. Therefore you cannot schedule a cron job to run every 30 seconds. The alternative way is to write a shell script that uses ‘sleep 30’ command in it.

    • @kovvurusubbu1460
      @kovvurusubbu1460 Год назад

      i have small problem in my kubernates pods some times not working and im daily manul restart all pods but im write script i dont now script ,,, your who to write script in this issue mr partha saradi

  • @bhupendramishra891
    @bhupendramishra891 2 года назад

    How can add 1 additional column in crontab script also how to change config for adding 1 column in exiting script

    • @aspiringarchitect209
      @aspiringarchitect209  2 года назад

      If you are looking to add another entry, you can use "crontab -e". To later verify list them using "crontab -l"

  • @moulijami530
    @moulijami530 2 года назад

    Can you say how can I check whether a scheduled job is running or not

  • @rajeswaridevithota8777
    @rajeswaridevithota8777 Год назад

    will you teach linux course in online can u please share the details?

  • @Karupakalasrilekha
    @Karupakalasrilekha Год назад

    bro.. i have a one doubt, How can we do for crontab jobs automatic backup, i mean all crontab jobs need to automatic backup. to store in an other location daily once... can please help me..

    • @aspiringarchitect209
      @aspiringarchitect209  Год назад

      By backing up do you mean maintaining a copy of the log files being generated? If so, you can develop a script with cp commands.

    • @Karupakalasrilekha
      @Karupakalasrilekha Год назад

      I will tell you this way.. we have 50 servers and maintaining about 40 jobs in each. Those jobs need to backup automatic daily(day by day with the date) once in separate server.
      If any body trying to change or when we increase and decrease we can easily find , when it happend who did that..
      This is the cause..

  • @dailyinternetclipz8624
    @dailyinternetclipz8624 2 года назад +1

    Thx u

  • @khajamohiddinpathan3446
    @khajamohiddinpathan3446 Год назад

    How to check script is working or not

    • @aspiringarchitect209
      @aspiringarchitect209  Год назад

      You can verify the output of your script.

    • @surajchavan160
      @surajchavan160 Год назад

      You can run, echo $?, if outcome shows value 0 then its correct if 1 then thr may be error