<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Script &#8211; CPYNET</title>
	<atom:link href="https://cpynet.com.tr/category/script/feed/" rel="self" type="application/rss+xml" />
	<link>https://cpynet.com.tr</link>
	<description>Yeni Nesil Teknoloji Platformu</description>
	<lastBuildDate>Wed, 20 Nov 2024 08:08:04 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://cpynet.com.tr/wp-content/uploads/2024/11/cropped-favicon-32x32.png</url>
	<title>Script &#8211; CPYNET</title>
	<link>https://cpynet.com.tr</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux&#8217;ta Startup Script Çalıştırma</title>
		<link>https://cpynet.com.tr/linuxta-startup-script-calistirma/</link>
		
		<dc:creator><![CDATA[Emin Buyuk]]></dc:creator>
		<pubDate>Tue, 05 Nov 2024 06:03:29 +0000</pubDate>
				<category><![CDATA[Script]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://cpynet-wordpress.wekeea.easypanel.host/linuxta-startup-script-calistirma/</guid>

					<description><![CDATA[Linux işletim sisteminde başlangıçta bir betik çalıştırmak bazen sunucu uygulamalarını otomatik olarak başlatmak gibi birçok senaryoda kullanışlıdır. Bu&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Linux işletim sisteminde başlangıçta bir betik çalıştırmak bazen sunucu uygulamalarını otomatik olarak başlatmak gibi birçok senaryoda kullanışlıdır. Bu makalede, bir betiği başlangıçta çalıştırmak için farklı yöntemleri inceleyeceğiz.</p>



<h3 class="wp-block-heading" id="1-basit-bir-betik-olu%C5%9Fturma">1. Basit Bir Betik Oluşturma</h3>



<p>Öncelikle, başlangıçta çalıştırılacak basit bir betik oluşturalım:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#!/bin/sh
echo &quot;Son yeniden başlatma zamanı: $(date)&quot; &gt; /etc/motd
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #6272A4">#!/bin/sh</span></span>
<span class="line"><span style="color: #F8F8F2">echo </span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">Son yeniden başlatma zamanı: $(date)</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">&gt;</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">etc</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">motd</span></span>
<span class="line"></span></code></pre></div>



<p>Bu betik, günlük mesajını (Message of the Day) sistemin son yeniden başlatma zamanıyla günceller. Kullanıcılar ilk oturum açtıklarında bu mesajı göreceklerdir.</p>



<p>Betik dosyasını kaydettikten sonra, çalıştırılabilir hale getirelim:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ chmod +x reboot_message.sh
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ chmod </span><span style="color: #FF79C6">+</span><span style="color: #F8F8F2">x reboot_message.sh</span></span>
<span class="line"></span></code></pre></div>



<h3 class="wp-block-heading" id="2-beti%C4%9Fin-ba%C5%9Flang%C4%B1%C3%A7ta-%C3%A7al%C4%B1%C5%9Ft%C4%B1r%C4%B1lmas%C4%B1">2. Betiğin Başlangıçta Çalıştırılması</h3>



<h4 class="wp-block-heading" id="21-cron-kullan%C4%B1m%C4%B1">2.1. cron Kullanımı</h4>



<p>En kolay yöntemlerden biri <code>cron</code> kullanmaktır. Bunun için <code>crontab</code> dosyasını düzenlememiz gerekecek:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ crontab -e
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ crontab </span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">e</span></span>
<span class="line"></span></code></pre></div>



<p><code>@reboot</code> ifadesi kullanılarak betiği başlangıçta çalıştıracak bir satır ekleyelim:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="@reboot sh /home/ec2-user/reboot_message.sh
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">@</span><span style="color: #50FA7B; font-style: italic">reboot</span><span style="color: #F8F8F2"> sh </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">home</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">ec2</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">user</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">reboot_message.sh</span></span>
<span class="line"></span></code></pre></div>



<p>Bu yöntem hızlı ve basit olsa da, her cron sürümü <code>@reboot</code> ifadesini desteklemez.</p>



<h4 class="wp-block-heading" id="22-rclocal-kullan%C4%B1m%C4%B1">2.2. rc.local Kullanımı</h4>



<p>Bir diğer yöntem ise <code>/etc/rc.d/rc.local</code> dosyasını kullanmaktır. Bu dosya zaten başlangıçta çalıştığı için, betiğimizi çağıran bir satır ekleyebiliriz:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="sh /home/ec2-user/reboot_message.sh
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">sh </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">home</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">ec2</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">user</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">reboot_message.sh</span></span>
<span class="line"></span></code></pre></div>



<p>Bu yöntemin çalışması için <code>rc.local</code> dosyasının çalıştırılabilir olduğundan emin olmalıyız:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ chmod +x /etc/rc.d/rc.local
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ chmod </span><span style="color: #FF79C6">+</span><span style="color: #F8F8F2">x </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">etc</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">rc.d</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">rc.local</span></span>
<span class="line"></span></code></pre></div>



<h4 class="wp-block-heading" id="23-initd-kullan%C4%B1m%C4%B1">2.3. init.d Kullanımı</h4>



<p><code>/etc/init.d</code> klasöründe, sistemin yönettiği servislerin yaşam döngüsü betikleri bulunur. Burada, betiğimizi başlatacak bir LSB uyumlu betik oluşturabiliriz:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="#! /bin/sh
# chkconfig: 345 99 10
case &quot;$1&quot; in
  start)
    # Betiğimizi çalıştırır
    sudo sh /home/ec2-user/reboot_message.sh
    ;;
  *)
    ;;
esac
exit 0
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #6272A4">#! /bin/sh</span></span>
<span class="line"><span style="color: #F8F8F2"># chkconfig: </span><span style="color: #BD93F9">345</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">99</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">10</span></span>
<span class="line"><span style="color: #FF79C6">case</span><span style="color: #F8F8F2"> </span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">$1</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">in</span></span>
<span class="line"><span style="color: #F8F8F2">  start)</span></span>
<span class="line"><span style="color: #F8F8F2">    # Betiğimizi çalıştırır</span></span>
<span class="line"><span style="color: #F8F8F2">    sudo sh </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">home</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">ec2</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">user</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">reboot_message.sh</span></span>
<span class="line"><span style="color: #F8F8F2">    ;;</span></span>
<span class="line"><span style="color: #F8F8F2">  </span><span style="color: #FF79C6">*</span><span style="color: #F8F8F2">)</span></span>
<span class="line"><span style="color: #F8F8F2">    ;;</span></span>
<span class="line"><span style="color: #F8F8F2">esac</span></span>
<span class="line"><span style="color: #F8F8F2">exit </span><span style="color: #BD93F9">0</span></span>
<span class="line"></span></code></pre></div>



<p>Bu betik <code>start</code> argümanıyla çağrıldığında betiği çalıştıracaktır. <code>chkconfig</code> satırı, betiğin çalıştırılma seviyesini ve önceliğini belirler.</p>



<p>Betiği <code>init.d</code> klasörüne yerleştirdikten sonra başlangıçta çalıştırılması için kaydetmemiz gerekir:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ chkconfig --add service_wrapper.sh
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ chkconfig </span><span style="color: #FF79C6">--</span><span style="color: #F8F8F2">add service_wrapper.sh</span></span>
<span class="line"></span></code></pre></div>



<p>Debian tabanlı sistemlerde <code>chkconfig</code> mevcut olmadığından, <code>update-rc.d</code> komutu kullanılabilir:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ update-rc.d service_wrapper.sh defaults
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ update</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">rc.d service_wrapper.sh defaults</span></span>
<span class="line"></span></code></pre></div>



<h4 class="wp-block-heading" id="24-systemd-kullan%C4%B1m%C4%B1">2.4. systemd Kullanımı</h4>



<p>Son olarak, systemd ile betik çalıştırma yöntemini inceleyelim. Bunun için <code>/etc/systemd/system</code> altında bir birim dosyası oluşturmalıyız:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="[Unit]
Description=Reboot message systemd servisi.

[Service]
Type=simple
ExecStart=/bin/bash /home/ec2-user/reboot_message.sh

[Install]
WantedBy=multi-user.target
" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">[Unit]</span></span>
<span class="line"><span style="color: #F8F8F2">Description</span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2">Reboot message systemd servisi.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">[Service]</span></span>
<span class="line"><span style="color: #F8F8F2">Type</span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2">simple</span></span>
<span class="line"><span style="color: #F8F8F2">ExecStart</span><span style="color: #FF79C6">=/</span><span style="color: #F8F8F2">bin</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">bash </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">home</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">ec2</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">user</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">reboot_message.sh</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">[Install]</span></span>
<span class="line"><span style="color: #F8F8F2">WantedBy</span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2">multi</span><span style="color: #FF79C6">-</span><span style="color: #F8F8F2">user.target</span></span>
<span class="line"></span></code></pre></div>



<p>Bu dosya farklı bölümlerden oluşur:</p>



<ul class="wp-block-list">
<li><strong>Unit</strong> – Genel meta verileri içerir.</li>



<li><strong>Service</strong> – Servisin davranışını ve başlatma komutunu açıklar.</li>



<li><strong>Install</strong> – Servisin başlatmada çalışmasını sağlar ve bağımlılıkları yönetir.</li>
</ul>



<p>Dosya izinlerini 644 olarak ayarladıktan sonra servisi etkinleştirelim:<code><br>
</code></p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="$ chmod 644 /etc/systemd/system/reboot_message.service 
$ systemctl enable reboot_message.service" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F8F8F2">$ chmod </span><span style="color: #BD93F9">644</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">etc</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">systemd</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">system</span><span style="color: #FF79C6">/</span><span style="color: #F8F8F2">reboot_message.service </span></span>
<span class="line"><span style="color: #F8F8F2">$ systemctl enable reboot_message.service</span></span></code></pre></div>



<p>Birçok dağıtım systemd&#8217;yi desteklese de, her zaman mevcut olmayabilir.</p>



<h3 class="wp-block-heading" id="3-sonu%C3%A7">3. Sonuç</h3>



<p>Bu makalede, Linux&#8217;ta bir betiği başlangıçta çalıştırmak için farklı yöntemleri inceledik. Mevcut olduğunda genellikle <code>systemd</code> ve <code>cron</code> tercih edilirken, <code>rc.local</code> ve <code>init.d</code> yedek seçenekler olarak kullanılabilir.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
